avoid silent data loss e.g., on NFS, due to unchecked close of stdout
authorJim Meyering <meyering@redhat.com>
Sun, 16 Aug 2009 09:39:07 +0000 (11:39 +0200)
committerJim Meyering <meyering@redhat.com>
Tue, 18 Aug 2009 07:28:05 +0000 (09:28 +0200)
* gzip.c: Include "closein.h".
(main): Use atexit (close_stdin);
* bootstrap.conf (gnulib_modules): Add closein.
Prompted by Mark Kidwell's report and patch in
http://bugs.debian.org/538187
* NEWS (Bug fixes): Mention it.
* */.gitignore: Update.

NEWS
bootstrap.conf
gzip.c
lib/.gitignore
m4/.gitignore

diff --git a/NEWS b/NEWS
index 90c2e6117c05e15d3da7db6e7ac51b8cf10259d2..0e6918d1db76a3429320b2a24fa1e64e76bd3314 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,8 @@ GNU gzip NEWS                                    -*- outline -*-
 
 ** Bug fixes
 
+  gzip no longer ignores a close-induced write failure, e.g., on NFS
+
 
 Major changes in Gzip 1.3.12 (2007-04-13)
 
index a617bd7c1b1967041995aadfe86f6c899083f263..7bc8ab62be4c6c1641ada5db64cfc0434717ee74 100644 (file)
@@ -23,6 +23,7 @@ IMPORT_FROM_GETTEXT=no
 
 # gnulib modules used by this package.
 gnulib_modules='
+       closein
        fcntl
        fcntl-safer
        fdl
diff --git a/gzip.c b/gzip.c
index b8916c1010c33ca24beb73eeb90c3de8c50826a7..71e0674dee6c9f3ab9536484bbecad3f2237b89f 100644 (file)
--- a/gzip.c
+++ b/gzip.c
@@ -64,6 +64,7 @@ static char rcsid[] = "$Id$";
 #include <sys/stat.h>
 #include <errno.h>
 
+#include "closein.h"
 #include "tailor.h"
 #include "gzip.h"
 #include "lzw.h"
@@ -417,6 +418,8 @@ int main (argc, argv)
     program_name = gzip_base_name (argv[0]);
     proglen = strlen (program_name);
 
+    atexit (close_stdin);
+
     /* Suppress .exe for MSDOS, OS/2 and VMS: */
     if (4 < proglen && strequ (program_name + proglen - 4, ".exe"))
       program_name[proglen - 4] = '\0';
index 27d515c41241b0a99110bc4dc7398ee92b9e2ca7..fc5cb8751ddda38bf0f7c94a09be09847fd18206 100644 (file)
@@ -1,6 +1,13 @@
 .deps
 Makefile
 Makefile.in
+close-stream.c
+close-stream.h
+closein.c
+closein.h
+closeout.c
+closeout.h
+config.charset
 config.h
 config.hin
 creat-safer.c
@@ -15,6 +22,16 @@ fcntl-safer.h
 fcntl.h
 fcntl.in.h
 fd-safer.c
+fflush.c
+fpending.c
+fpending.h
+fpurge.c
+freadahead.c
+freadahead.h
+freading.c
+freading.h
+fseeko.c
+ftello.c
 getopt.c
 getopt.in.h
 getopt1.c
@@ -23,16 +40,29 @@ gettext.h
 gnulib.mk
 intprops.h
 libgzip.a
+localcharset.c
+localcharset.h
+lseek.c
+mbrtowc.c
+mbsinit.c
 open-safer.c
 open.c
 pipe-safer.c
+quotearg.c
+quotearg.h
+ref-add.sin
+ref-del.sin
 stamp-h1
 stat-time.h
 stdbool.in.h
 stddef.in.h
 stdint.in.h
+stdio-impl.h
+stdio-write.c
+stdio.in.h
 stdlib.h
 stdlib.in.h
+streq.h
 strerror.c
 string.h
 string.in.h
@@ -47,7 +77,9 @@ unistd.h
 unistd.in.h
 utimens.c
 utimens.h
+verify.h
 wchar.in.h
+wctype.in.h
 xalloc-die.c
 xalloc.h
 xmalloc.c
index 59a68c6f7f318952ac74b4b3ad76a5af4d63c536..e2e2d820e2212f6a4502ec68bdf1f63712a32c0c 100644 (file)
@@ -1,11 +1,22 @@
 00gnulib.m4
+close-stream.m4
+closein.m4
+closeout.m4
+codeset.m4
 errno_h.m4
 error.m4
 exitfail.m4
 extensions.m4
 fcntl-safer.m4
 fcntl_h.m4
+fflush.m4
+fpending.m4
+fpurge.m4
+freading.m4
+fseeko.m4
+ftello.m4
 getopt.m4
+glibc21.m4
 gnu-make.m4
 gnulib-cache.m4
 gnulib-common.m4
@@ -13,14 +24,24 @@ gnulib-comp.m4
 gnulib-tool.m4
 include_next.m4
 inline.m4
+localcharset.m4
+locale-fr.m4
+locale-ja.m4
+locale-zh.m4
 longlong.m4
+lseek.m4
+mbrtowc.m4
+mbsinit.m4
+mbstate_t.m4
 mode_t.m4
 multiarch.m4
 open.m4
+quotearg.m4
 stat-time.m4
 stdbool.m4
 stddef_h.m4
 stdint.m4
+stdio_h.m4
 stdlib_h.m4
 strerror.m4
 string_h.m4
@@ -34,6 +55,7 @@ utimens.m4
 utimes.m4
 wchar.m4
 wchar_t.m4
+wctype.m4
 wint_t.m4
 xalloc.m4
 yesno.m4