[Bug ada/79309] incorrectly bounded calls to strncat in adaint.c
msebor at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Jan 31 20:38:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79309
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |build, patch
--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
The following patch fixes the problem:
diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index 54a1d6e..483997f 100644
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -3401,9 +3401,8 @@ void __gnat_killprocesstree (int pid, int sig_num)
/* read /proc/<PID>/stat */
- strncpy (statfile, "/proc/", sizeof(statfile));
- strncat (statfile, d->d_name, sizeof(statfile));
- strncat (statfile, "/stat", sizeof(statfile));
+ sprintf (statfile, "/proc/%.*s/stat",
+ (int)(sizeof statfile - 12), d->d_name);
FILE *fd = fopen (statfile, "r");
More information about the Gcc-bugs
mailing list