]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Fix inflateInit2() bug when windowBits is 16 or 32.
authorMark Adler <madler@alumni.caltech.edu>
Wed, 29 Jul 2015 04:41:20 +0000 (21:41 -0700)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Tue, 3 Nov 2015 14:34:05 +0000 (15:34 +0100)
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.

(cherry picked from commit 0db8fd371477f42c280ddeee29e6de092fabf948)

inflate.c

index 321f9e5de3cbdd641d05bed99f9ddf169c6f564e..b695229a2c218da3e077f9ec22bc71b0cce0d53f 100644 (file)
--- a/inflate.c
+++ b/inflate.c
@@ -613,6 +613,8 @@ int ZEXPORT inflate(z_stream *strm, 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();