Avoid memory overrun in a test leading to potential double-free.

2011-04-10  Jim Meyering  <meyering@redhat.com>

	    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
This commit is contained in:
Jim Meyering 2011-04-10 18:13:23 +00:00 committed by Mike Stump
parent 5b2d2d52fe
commit 4b9726d48c
2 changed files with 7 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2011-04-10 Jim Meyering <meyering@redhat.com>
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 <gingold@adacore.com>
* makefile.vms (OBJS): Add filename_cmp.obj

View File

@ -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);