From: Daniel Barkalow Date: Sat, 10 Oct 2009 09:35:13 +0000 (+0200) Subject: gzip: don't fail when there is exactly one trailing NUL byte X-Git-Tag: v1.3.14~7 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=118a107f2d3ae5267b42e1aaac58a8b5ce9d1925;p=debian%2Fgzip gzip: don't fail when there is exactly one trailing NUL byte * gzip.c (get_method): Require the second byte of magic only if the first byte was nonzero. --- diff --git a/gzip.c b/gzip.c index 8543128..b0f792a 100644 --- a/gzip.c +++ b/gzip.c @@ -1266,8 +1266,13 @@ local int get_method(in) /* 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 */