Subject: Re: bin/33045: NetBSD gzip rejects files GNU gzip accepts
To: None <mlelstv@NetBSD.org, gnats-admin@netbsd.org,>
From: Michael van Elst <mlelstv@serpens.de>
List: netbsd-bugs
Date: 10/09/2006 07:25:02
The following reply was made to PR bin/33045; it has been noted by GNATS.

From: Michael van Elst <mlelstv@serpens.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/33045: NetBSD gzip rejects files GNU gzip accepts
Date: Mon, 9 Oct 2006 09:23:59 +0200

 The following patch will end a decompression when trailing garbage
 is found. It emits a warning message and causes a non-zero exit
 status (similar to GNU gzip).
 
 
 Index: gzip.c
 ===================================================================
 RCS file: /cvsroot/src/usr.bin/gzip/gzip.c,v
 retrieving revision 1.85
 diff -u -r1.85 gzip.c
 --- gzip.c	27 Sep 2006 22:20:31 -0000	1.85
 +++ gzip.c	9 Oct 2006 07:06:51 -0000
 @@ -751,6 +751,10 @@
  		switch (state) {
  		case GZSTATE_MAGIC0:
  			if (*z.next_in != GZIP_MAGIC0) {
 +				if (in_tot > 0) {
 +					maybe_warnx("%s: trailing garbage ignored", filename);
 +					goto stop;
 +				}
  				maybe_warnx("input not gziped (MAGIC0)");
  				goto stop_and_fail;
  			}
 
 -- 
                                 Michael van Elst
 Internet: mlelstv@serpens.de
                                 "A potential Snark may lurk in every tree."