GNU bug report logs - #9762
tac fails when given multiple non-seekable inputs due to misuse of mkstemp()

Previous Next

Package: coreutils;

Reported by: Ambrose Feinstein <ambrose <at> google.com>

Date: Sat, 15 Oct 2011 20:58:01 UTC

Severity: normal

Done: Jim Meyering <jim <at> meyering.net>

Bug is archived. No further changes may be made.

Full log


Message #23 received at 9762 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Jim Meyering <jim <at> meyering.net>
Cc: 9762 <at> debbugs.gnu.org
Subject: Re: bug#9762: tac fails when given multiple non-seekable inputs due
	to misuse of mkstemp()
Date: Mon, 17 Oct 2011 10:24:19 -0700
On 10/17/11 08:18, Jim Meyering wrote:
>> +      char const * const Template = "tacXXXXXX";

That "const * const" prompted me to suggest a minor
improvement.  Since Template's address is never taken,
better would be

  char const Template[] = "tacXXXXXX";

Hmm, or better yet, get rid of Template entirely:

--- a/src/tac.c
+++ b/src/tac.c
@@ -430,12 +430,11 @@ copy_to_temp (FILE **g_tmp, char **g_tempfile, int input_fd, char const *file)
 
   if (template == NULL)
     {
-      char const * const Template = "tacXXXXXX";
       tempdir = getenv ("TMPDIR");
       if (tempdir == NULL)
         tempdir = DEFAULT_TMPDIR;
 
-      template = file_name_concat (tempdir, Template, NULL);
+      template = file_name_concat (tempdir, "tacXXXXXX", NULL);
     }
 
   /* FIXME: there's a small window between a successful mkstemp call




This bug report was last modified 13 years and 223 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.