From 74461ba2eeb0d77205c732419ab5ce5832b1caca Mon Sep 17 00:00:00 2001 From: Puck Meerburg Date: Sun, 13 Dec 2020 18:27:08 +0000 Subject: Follow RFC1952 when consuming gzip header The FEXTRA field, indicated by bit 2 of the flag byte, contains arbitrary extra data, prefixed by a 16-bit length value. The previous code skipped over the length, but not the actual contents, breaking decompression of certain files. --- lib/deflate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/deflate.c') diff --git a/lib/deflate.c b/lib/deflate.c index eebcd3de..8c724429 100644 --- a/lib/deflate.c +++ b/lib/deflate.c @@ -403,7 +403,7 @@ static int is_gzip(struct bitbuf *bb) bitbuf_skip(bb, 6*8); // Skip extra, name, comment, header CRC fields - if (flags & 4) bitbuf_skip(bb, 16); + if (flags & 4) bitbuf_skip(bb, bitbuf_get(bb, 16) * 8); if (flags & 8) while (bitbuf_get(bb, 8)); if (flags & 16) while (bitbuf_get(bb, 8)); if (flags & 2) bitbuf_skip(bb, 16); -- cgit v1.2.3