aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPuck Meerburg <puck@puck.moe>2020-12-13 18:27:08 +0000
committerRob Landley <rob@landley.net>2020-12-14 02:09:36 -0600
commit74461ba2eeb0d77205c732419ab5ce5832b1caca (patch)
tree81f449af0fd6a5e83597b65f051a7c471a99582f /lib
parent769b8a1c42a1c44fec930795fd3ce8799ec39537 (diff)
downloadtoybox-74461ba2eeb0d77205c732419ab5ce5832b1caca.tar.gz
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/deflate.c2
1 files changed, 1 insertions, 1 deletions
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);