The code to ignore trailing zeros from:
* gzip.c (get_method): Don't complain about trailing zeros at
the end of a gzipped file, as they're commonly appended to fill
out a block (e.g. by GNU tar).
has a rare bug: if there is exactly one trailing zero (because, for
example, your compressed tar file was one byte short of a block), gzip
gets only the first byte of the magic, and it's zero, but then it hits the
end of the file on the second byte of the magic.
I think this should affect only that case, and make it not fail:
--- gzip.c~ 2009-09-26 14:56:02.000000000 -0400
+++ gzip.c 2009-10-09 18:17:39.000000000 -0400
@@ -1266,8 +1266,13 @@
/* If try_byte returned EOF, magic[1] == (char) EOF. */
} else {
magic[0] = (char)get_byte();
- magic[1] = (char)get_byte();
- imagic1 = 0; /* avoid lint warning */
+ if (magic[0]) {
+ magic[1] = (char)get_byte();
+ imagic1 = 0; /* avoid lint warning */
+ } else {
+ imagic1 = try_byte ();
+ magic[1] = (char) imagic1;
+ }
}
method = -1; /* unknown yet */
part_nb++; /* number of parts in gzip file */