From 118a107f2d3ae5267b42e1aaac58a8b5ce9d1925 Mon Sep 17 00:00:00 2001 From: Daniel Barkalow Date: Sat, 10 Oct 2009 11:35:13 +0200 Subject: [PATCH] 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. --- gzip.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 */ -- 2.47.2