summaryrefslogtreecommitdiff
path: root/src/tac.c
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2008-08-13 20:53:12 +0200
committerJim Meyering <meyering@redhat.com>2008-08-14 14:37:37 +0200
commit22999697b81acf3e8683c95c310a36926e7af96f (patch)
treef1ef3a5e94aca978886adde6bc0aa4ce6553c1aa /src/tac.c
parent7e0019b168241b4edb79cc454d00dfc3344df8c7 (diff)
downloadcoreutils-22999697b81acf3e8683c95c310a36926e7af96f.tar.xz
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.
Diffstat (limited to 'src/tac.c')
-rw-r--r--src/tac.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/tac.c b/src/tac.c
index 9cf6d60dc..c83986f59 100644
--- a/src/tac.c
+++ b/src/tac.c
@@ -454,7 +454,8 @@ copy_to_temp (FILE **g_tmp, char **g_tempfile, int input_fd, char const *file)
fd = mkstemp (template);
if (fd < 0)
{
- error (0, errno, _("cannot create temporary file %s"), quote (tempfile));
+ error (0, errno, _("cannot create temporary file in %s"),
+ quote (tempdir));
return false;
}