[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
-fprint F corrupts output, F, when stderr is closed
From: |
Jim Meyering |
Subject: |
-fprint F corrupts output, F, when stderr is closed |
Date: |
Fri, 01 Jul 2005 12:33:35 +0200 |
[ Sorry to report a bug to the list, but I dislike
filling in web forms. If there were a
mail-to-savannah-bug gateway I'd be happy to use it. ]
When stderr is initially closed, find's `-fprint F'
and `-fprintf F' predicates can corrupt their output file F
with diagnostic output intended for the closed stderr stream.
$ find no-such -fprint FF 2>&-
[Exit 1]
$ cat FF
find: no-such: No such file or directory
Here's the patch:
(assuming you get lib/stdio-safer.[ch] from coreutils --
I'll see about getting it into gnulib)
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 10:14:58 -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);
- -fprint F corrupts output, F, when stderr is closed,
Jim Meyering <=