From 22999697b81acf3e8683c95c310a36926e7af96f Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Wed, 13 Aug 2008 20:53:12 +0200 Subject: mktemp, sort, tac: don't use undefined after mkstemp failure When mkstemp fails, the template buffer may have undefined contents, so we must not print it. * src/sort.c (create_temp_file): Use temp_dir, not "file" when diagnosing failed mkstemp, because "file" may be undefined. * tests/misc/sort-merge: Adjust for new expected output. Jeph Cowan and Ralf Wildenhues reported the test failure: http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/14235/focus=14257 * src/tac.c (copy_to_temp): Don't use template buffer after failed mkstemp call, since its contents may be undefined. * tests/misc/tac (pipe-bad-tmpdir): New test for the above. * src/mktemp.c (main): Save a copy of the template string, solely for use in case mkstemp fails. * tests/misc/mktemp (pipe-bad-tmpdir): New test for the above. --- tests/misc/sort-merge | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests/misc/sort-merge') diff --git a/tests/misc/sort-merge b/tests/misc/sort-merge index 985d7a414..6b8192610 100755 --- a/tests/misc/sort-merge +++ b/tests/misc/sort-merge @@ -66,8 +66,9 @@ my @Tests = # this should fail since nmerge < # of input files, so # temp files are needed ['nmerge-no', "-m --batch-size=2 -T$badtmp", @inputs, - {ERR_SUBST=>"s|: $badtmp/sort.+||"}, - {ERR=>"$prog: cannot create temporary file\n"}, {EXIT=>2}], + {ERR_SUBST=>"s|': .*|':|"}, + {ERR=>"$prog: cannot create temporary file in `$badtmp':\n"}, + {EXIT=>2}], # This used to fail because setting batch-size without also setting # buffer size would cause the buffer size to be set to the minimum. -- cgit v1.2.3-70-g09d2