From 0d36ec47f310478549c0864f215ab5c0114c49ba Mon Sep 17 00:00:00 2001 From: Mark Adler Date: Wed, 2 Jan 2019 18:10:40 -0800 Subject: Don't bother computing check value after successful inflateSync(). inflateSync() is used to skip invalid deflate data, which means that the check value that was being computed is no longer useful. This commit turns off the check value computation, and furthermore allows a successful return if the compressed data terminated in a graceful manner. This commit also fixes a bug in the case that inflateSync() is used before a header is ever processed. In that case, there is no knowledge of a trailer, so the remainder is treated as raw. --- inflate.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'inflate.h') diff --git a/inflate.h b/inflate.h index a46cce6..98679fa 100644 --- a/inflate.h +++ b/inflate.h @@ -86,7 +86,8 @@ struct inflate_state { int wrap; /* bit 0 true for zlib, bit 1 true for gzip, bit 2 true to validate check value */ int havedict; /* true if dictionary provided */ - int flags; /* gzip header method and flags (0 if zlib) */ + int flags; /* gzip header method and flags, 0 if zlib, or + -1 if raw or no header yet */ unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ unsigned long check; /* protected copy of check value */ unsigned long total; /* protected copy of output count */ -- cgit v1.2.3-55-g6feb