From 0db8fd371477f42c280ddeee29e6de092fabf948 Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Tue, 28 Jul 2015 21:41:20 -0700 Subject: [PATCH] Fix inflateInit2() bug when windowBits is 16 or 32. A windowBits value of 0, 16, or 32 gets the window bits from the zlib header. However there is no zlib header for 16, or for 32 when the input is gzip. This commit sets the window bits for inflate to 15 if a gzip stream is detected and windowBits was 16 or 32. --- inflate.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/inflate.c b/inflate.c index 82e39be..2889e3a 100644 --- a/inflate.c +++ b/inflate.c @@ -645,6 +645,8 @@ int flush; NEEDBITS(16); #ifdef GUNZIP if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ + if (state->wbits == 0) + state->wbits = 15; state->check = crc32(0L, Z_NULL, 0); CRC2(state->check, hold); INITBITS();