zlib/backport-Handle-case-where-inflateSync-used-when-header-never.patch
zhoupengcheng fce1c5536a zlib:backport upstream patch
(cherry picked from commit ee65ab90886d1240dc7ef6b6afc98012d7c18b2a)
2024-05-07 19:57:31 +08:00

36 lines
1.2 KiB
Diff

From 44e8ac810d7d50381429a15cdc6e48816beafd2b Mon Sep 17 00:00:00 2001
From: Mark Adler <madler@alumni.caltech.edu>
Date: Sun, 16 Apr 2017 08:35:33 -0700
Subject: [PATCH] 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.
Reference:https://github.com/madler/zlib/commit/44e8ac810d7d50381429a15cdc6e48816beafd2b
Conflict:NA
---
inflate.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/inflate.c b/inflate.c
index a4b5b68..575fcdf 100644
--- a/inflate.c
+++ b/inflate.c
@@ -1433,6 +1433,8 @@ z_streamp 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;
inflateReset(strm);
strm->total_in = in; strm->total_out = out;
--
2.23.0