Open
Description
zlib-ng can't handle windowBits=8. This is fine. What is not fine is that instead of crashing it starts deflating with windowBits=9. As a result when inflating again with windowBits=8 it crashes with an invalid window size. This crash occurs to late. If zng_deflateInit2 finds that the data cannot be deflated using the user-requested settings it should crash right away and notify the user of this problem. Verbosely crashing is better than silently subverting user expectations and then mysteriously crashing later elsewhere.
The following code causes the issue: https://github.com/zlib-ng/zlib-ng/blob/c255e58dd5e0ec3b2febb29c0905e89032419bcd/deflate.c#L227-228
if (windowBits == 8)
windowBits = 9; /* until 256-byte window bug fixed */
This should be
if (windowBits == 8) {
strm.msg = "zlib-ng does not support windowBits=8 yet, 256-byte windows are bugged.";
return Z_STREAM_ERROR;
}
Metadata
Metadata
Assignees
Labels
No labels
Activity