aboutsummaryrefslogtreecommitdiff
path: root/inflate.c
diff options
context:
space:
mode:
authorMark Adler <madler@alumni.caltech.edu>2015-07-28 21:41:20 -0700
committerMark Adler <madler@alumni.caltech.edu>2015-07-28 21:41:20 -0700
commit0db8fd371477f42c280ddeee29e6de092fabf948 (patch)
treeb145f597894d1c211554d94e63d96af64042604b /inflate.c
parentb56d1c62ee1ff9705026c94a780dd6e4577cda02 (diff)
downloadzlib-0db8fd371477f42c280ddeee29e6de092fabf948.tar.gz
zlib-0db8fd371477f42c280ddeee29e6de092fabf948.tar.bz2
zlib-0db8fd371477f42c280ddeee29e6de092fabf948.zip
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.
Diffstat (limited to 'inflate.c')
-rw-r--r--inflate.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/inflate.c b/inflate.c
index 82e39be..2889e3a 100644
--- a/inflate.c
+++ b/inflate.c
@@ -645,6 +645,8 @@ int flush;
645 NEEDBITS(16); 645 NEEDBITS(16);
646#ifdef GUNZIP 646#ifdef GUNZIP
647 if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */ 647 if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
648 if (state->wbits == 0)
649 state->wbits = 15;
648 state->check = crc32(0L, Z_NULL, 0); 650 state->check = crc32(0L, Z_NULL, 0);
649 CRC2(state->check, hold); 651 CRC2(state->check, hold);
650 INITBITS(); 652 INITBITS();