]> git.ipfire.org Git - thirdparty/zlib-ng.git/commit
Fix block_open handling in deflate_quick()
authorIlya Leoshkevich <iii@linux.ibm.com>
Wed, 17 Mar 2021 00:14:41 +0000 (01:14 +0100)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Wed, 17 Mar 2021 09:08:32 +0000 (10:08 +0100)
commitff0ab283f0b50e909e9bbb3620f3f401f2eb1491
tree66418336c5a03ff9126f2bc5eae186a74fac2c87
parentac18b0c35c8cf56bcc2531e100372f654390923b
Fix block_open handling in deflate_quick()

The attached test fails with "inflate() failed", because the deflate
stream that it produces ends up being corrupted. Bisect points to the
commit e7bb6db09a18 ("Replace hash_bits, hash_size and hash_mask with
defines."), but it's most likely a coincidence.

In any case, the reason is that if we happen to simultaneously exhaust
all the buffers (in, out and bi), we return finish_started without
writing the end of block symbol, which will never happen afterwards.

Fix by adding another check to the tricky condition: if we are in the
middle of a block, return need_more instead of finish_started.
CMakeLists.txt
deflate_quick.c
test/deflate_quick_block_open.c [new file with mode: 0644]