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. --- test/example.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/example.c b/test/example.c index eee17ce..949f4f6 100644 --- a/test/example.c +++ b/test/example.c @@ -440,9 +440,8 @@ void test_sync(compr, comprLen, uncompr, uncomprLen) CHECK_ERR(err, "inflateSync"); err = inflate(&d_stream, Z_FINISH); - if (err != Z_DATA_ERROR) { - fprintf(stderr, "inflate should report DATA_ERROR\n"); - /* Because of incorrect adler32 */ + if (err != Z_STREAM_END) { + fprintf(stderr, "inflate should report Z_STREAM_END\n"); exit(1); } err = inflateEnd(&d_stream); -- cgit v1.2.3-55-g6feb