bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

complete patch for -fprint vs. closed stderr bug


From: Jim Meyering
Subject: complete patch for -fprint vs. closed stderr bug
Date: Fri, 01 Jul 2005 21:02:12 +0200

In case you haven't already gotten to it, here's the
patch I sent a few hours ago, but with the import-gnulib.sh
part and a ChangeLog:

Demonstrate that pre-patched find has the bug:
  $ find no-such -fprint FF 2>&- || cat FF
  find: no-such: No such file or directory

Demonstrate that it's fixed in the patched find:
  $ ./find no-such -fprint FF 2>&- || cat FF

2005-07-01  Jim Meyering  <address@hidden>

        With `-fprint F' or `-fprintf F', don't write diagnostics
        to F when stderr is closed.

        * find/parser.c: Include "stdio-safer.h".
        (open_output_file): Use fopen_safer, not fopen.
        * import-gnulib.sh (findutils_modules): Add stdio-safer.

Index: import-gnulib.sh
===================================================================
RCS file: /cvsroot/findutils/findutils/import-gnulib.sh,v
retrieving revision 1.20
diff -u -p -r1.20 import-gnulib.sh
--- import-gnulib.sh    7 Jun 2005 22:24:56 -0000       1.20
+++ import-gnulib.sh    1 Jul 2005 18:54:01 -0000
@@ -41,8 +41,8 @@ destdir="gnulib"
 # Modules needed for findutils itself.
 findutils_modules="\
 alloca  argmatch  dirname error fileblocks  fnmatch-gnu  \
-getline getopt human idcache  lstat malloc memcmp memset mktime          \
-modechange   pathmax quotearg realloc regex rpmatch savedir stat  \
+getline getopt human idcache lstat malloc memcmp memset mktime \
+modechange pathmax quotearg realloc regex rpmatch savedir stat stdio-safer \
 stpcpy strdup strftime  strstr strtol strtoul strtoull strtoumax  \
 xalloc xalloc-die xgetcwd  xstrtol  xstrtoumax yesno human filemode \
 getline stpcpy canonicalize mountlist closeout gettext stat-macros"
Index: find/parser.c
===================================================================
RCS file: /cvsroot/findutils/findutils/find/parser.c,v
retrieving revision 1.71
diff -u -p -r1.71 parser.c
--- find/parser.c       18 Jun 2005 10:37:24 -0000      1.71
+++ find/parser.c       1 Jul 2005 18:54:02 -0000
@@ -32,6 +32,7 @@
 #include "quotearg.h"
 #include "buildcmd.h"
 #include "nextelem.h"
+#include "stdio-safer.h"
 
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
@@ -2430,7 +2431,7 @@ open_output_file (char *path)
     return (stderr);
   else if (!strcmp (path, "/dev/stdout"))
     return (stdout);
-  f = fopen (path, "w");
+  f = fopen_safer (path, "w");
   if (f == NULL)
     error (1, errno, "%s", path);
   return (f);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]