From f17cbd13a1d0a7dcf067a1cdba89e9f668ce7d15 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 26 Sep 2009 21:22:02 +0200 Subject: [PATCH] gzip: don't use an uninitialized file descriptor gzip interprets an argument of "-" as indicating stdin, but when "-" is not the first name on the command line, it doesn't work. * gzip.c (treat_stdin): Initialize "ifd". Patch and fine description by Lasse Collin in http://www.mail-archive.com/bug-gzip@gnu.org/msg00213.html * Makefile.am (check-local): Exercise the fix. Based on the above. * NEWS (Bug fixes): Mention this. --- Makefile.am | 2 ++ NEWS | 2 ++ gzip.c | 1 + 3 files changed, 5 insertions(+) diff --git a/Makefile.am b/Makefile.am index a73becf..8023f5b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -95,6 +95,8 @@ check-local: $(FILES_TO_CHECK) $(bin_PROGRAMS) gzip.doc.gz done ./gzip -dc $(srcdir)/tests/hufts-segv.gz > /dev/null 2>&1; \ test $$? = 1 + k=in-$$$$; printf a | ./gzip > $$k && \ + test "`cat $$k | ./gzip -dc $$k - $$k`" = aaa && rm $$k @echo 'Test succeeded.' install-exec-hook: remove-installed-links diff --git a/NEWS b/NEWS index 947a153..c9e9254 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,8 @@ GNU gzip NEWS -*- outline -*- ** Bug fixes + gzip -d no longer fails with "-" as 2nd or subsequent argument + gzip no longer ignores a close-induced write failure, e.g., on NFS gzip -d no longer segfaults on certain invalid inputs diff --git a/gzip.c b/gzip.c index fc2e7dc..8543128 100644 --- a/gzip.c +++ b/gzip.c @@ -650,6 +650,7 @@ local void treat_stdin() clear_bufs(); /* clear input and output buffers */ to_stdout = 1; part_nb = 0; + ifd = fileno(stdin); if (decompress) { method = get_method(ifd); -- 2.47.2