From: Jim Meyering Date: Sun, 10 Apr 2011 18:13:23 +0000 (+0000) Subject: Avoid memory overrun in a test leading to potential double-free. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4b9726d48cc7eea7e51b51e00e3720104cd2774f;p=gcc.git Avoid memory overrun in a test leading to potential double-free. 2011-04-10 Jim Meyering Avoid memory overrun in a test leading to potential double-free. * testsuite/test-expandargv.c (writeout_test): Fix off-by-one error: i.e., do copy the trailing NUL byte. From-SVN: r172246 --- diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog index f6138b69e24..a15ffa59d28 100644 --- a/libiberty/ChangeLog +++ b/libiberty/ChangeLog @@ -1,3 +1,9 @@ +2011-04-10 Jim Meyering + + Avoid memory overrun in a test leading to potential double-free. + * testsuite/test-expandargv.c (writeout_test): Fix off-by-one error: + i.e., do copy the trailing NUL byte. + 2011-03-31 Tristan Gingold * makefile.vms (OBJS): Add filename_cmp.obj diff --git a/libiberty/testsuite/test-expandargv.c b/libiberty/testsuite/test-expandargv.c index c16a0322a6c..57b96b3ff97 100644 --- a/libiberty/testsuite/test-expandargv.c +++ b/libiberty/testsuite/test-expandargv.c @@ -204,7 +204,7 @@ writeout_test (int test, const char * test_data) if (parse == NULL) fatal_error (__LINE__, "Failed to malloc parse.", errno); - memcpy (parse, test_data, sizeof (char) * len); + memcpy (parse, test_data, sizeof (char) * (len + 1)); /* Run all possible replaces */ run_replaces (parse);