From: Mark Adler Date: Sun, 16 Apr 2017 15:35:33 +0000 (-0700) Subject: Handle case where inflateSync used when header never processed. X-Git-Tag: 1.9.9-b1~585 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3cbd82cffce0d0f9021fc2f3a715a27f3edddd5b;p=thirdparty%2Fzlib-ng.git Handle case where inflateSync used when header never processed. If zlib and/or gzip header processing was requested, but a header was never provided and inflateSync was used successfully, then the inflate state would be inconsistent, trying to compute a check value but with no flags set. This commit sets the inflate mode to raw in this case, since there is no other assumption that can be made if a header was requested but never seen. --- diff --git a/inflate.c b/inflate.c index cb84adb6d..d2e621eaa 100644 --- a/inflate.c +++ b/inflate.c @@ -1409,6 +1409,8 @@ int ZEXPORT PREFIX(inflateSync)(PREFIX3(stream) *strm) { /* return no joy or set up to restart inflate() on a new block */ if (state->have != 4) return Z_DATA_ERROR; + if (state->mode == HEAD) + state->wrap = 0; /* never processed header, so assume raw */ in = strm->total_in; out = strm->total_out; PREFIX(inflateReset)(strm);