]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Handle case where inflateSync used when header never processed.
authorMark Adler <madler@alumni.caltech.edu>
Sun, 16 Apr 2017 15:35:33 +0000 (08:35 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Thu, 13 Dec 2018 13:21:20 +0000 (14:21 +0100)
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.

inflate.c

index cb84adb6d1b1ff4558fc1d4d7824693c28fe7ad2..d2e621eaa67ec0f8766ceabcfe04770335baaeea 100644 (file)
--- 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);