Subject: Re: bin/32933: gzip -tv reports (some?) truncated files as OK
To: None <mlelstv@NetBSD.org, gnats-admin@netbsd.org,>
From: Michael van Elst <mlelstv@serpens.de>
List: netbsd-bugs
Date: 10/08/2006 23:15:05
The following reply was made to PR bin/32933; it has been noted by GNATS.

From: Michael van Elst <mlelstv@serpens.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/32933: gzip -tv reports (some?) truncated files as OK
Date: Mon, 9 Oct 2006 01:10:46 +0200

 Here is a patch that helps with this problem and also with bin/33045:
 
 Index: gzip.c
 ===================================================================
 RCS file: /cvsroot/src/usr.bin/gzip/gzip.c,v
 retrieving revision 1.82
 diff -u -r1.82 gzip.c
 --- gzip.c	13 Jul 2006 11:51:39 -0000	1.82
 +++ gzip.c	8 Oct 2006 23:05:20 -0000
 @@ -743,14 +743,18 @@
  			in_tot += in_size;
  		}
  		if (z.avail_in == 0) {
 -			if (done_reading && state != GZSTATE_MAGIC0)
 +			if (done_reading && state != GZSTATE_MAGIC0) {
  				maybe_warnx("%s: unexpected end of file",
  					    filename);
 +				goto stop_and_fail;
 +			}
  			goto stop;
  		}
  		switch (state) {
  		case GZSTATE_MAGIC0:
  			if (*z.next_in != GZIP_MAGIC0) {
 +				if (out_tot > 0)
 +					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."