diff options
author | Mark Adler <madler@alumni.caltech.edu> | 2017-04-16 08:35:33 -0700 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2017-04-16 08:35:33 -0700 |
commit | 44e8ac810d7d50381429a15cdc6e48816beafd2b (patch) | |
tree | 751b95f60660f77e237a93ff76e2299facc77bbf | |
parent | 89245c0a84eac0c5cfc6f0eb2fe72854f4b2c9e6 (diff) | |
download | zlib-44e8ac810d7d50381429a15cdc6e48816beafd2b.tar.gz zlib-44e8ac810d7d50381429a15cdc6e48816beafd2b.tar.bz2 zlib-44e8ac810d7d50381429a15cdc6e48816beafd2b.zip |
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.
-rw-r--r-- | inflate.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -1433,6 +1433,8 @@ z_streamp strm; | |||
1433 | 1433 | ||
1434 | /* return no joy or set up to restart inflate() on a new block */ | 1434 | /* return no joy or set up to restart inflate() on a new block */ |
1435 | if (state->have != 4) return Z_DATA_ERROR; | 1435 | if (state->have != 4) return Z_DATA_ERROR; |
1436 | if (state->mode == HEAD) | ||
1437 | state->wrap = 0; /* never processed header, so assume raw */ | ||
1436 | in = strm->total_in; out = strm->total_out; | 1438 | in = strm->total_in; out = strm->total_out; |
1437 | inflateReset(strm); | 1439 | inflateReset(strm); |
1438 | strm->total_in = in; strm->total_out = out; | 1440 | strm->total_in = in; strm->total_out = out; |