summaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2017-02-01 20:36:23 +0000
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>2017-02-01 20:36:23 +0000
commit2ed67d5fff211f6e26b6c858445191a965938003 (patch)
tree421bbefb89474fb4f95af741b1c63d736e807737 /gcc/ada
parenta1b0b75cfc4f82162fc7e9b1f7255c98359a1078 (diff)
downloadgcc-2ed67d5fff211f6e26b6c858445191a965938003.tar.gz
PR ada/79309
* adaint.c (__gnat_killprocesstree): Fix broken string handling. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@245103 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/adaint.c10
2 files changed, 12 insertions, 4 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 8f394b03ca9..387cfbfc559 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,9 @@
+2017-02-01 Eric Botcazou <ebotcazou@adacore.com>
+ Jakub Jelinek <jakub@redhat.com>
+
+ PR ada/79309
+ * adaint.c (__gnat_killprocesstree): Fix broken string handling.
+
2017-01-25 Maxim Ostapenko <m.ostapenko@samsung.com>
PR lto/79061
diff --git a/gcc/ada/adaint.c b/gcc/ada/adaint.c
index 54a1d6e25c3..e5fea3eefe0 100644
--- a/gcc/ada/adaint.c
+++ b/gcc/ada/adaint.c
@@ -3396,14 +3396,16 @@ void __gnat_killprocesstree (int pid, int sig_num)
{
if ((d->d_type & DT_DIR) == DT_DIR)
{
- char statfile[64] = { 0 };
+ char statfile[64];
int _pid, _ppid;
/* read /proc/<PID>/stat */
- strncpy (statfile, "/proc/", sizeof(statfile));
- strncat (statfile, d->d_name, sizeof(statfile));
- strncat (statfile, "/stat", sizeof(statfile));
+ if (strlen (d->d_name) >= sizeof (statfile) - sizeof ("/proc//stat"))
+ continue;
+ strcpy (statfile, "/proc/");
+ strcat (statfile, d->d_name);
+ strcat (statfile, "/stat");
FILE *fd = fopen (statfile, "r");