Skip to content

zng_deflateInit2 silently converts windowBits=8 to windowBits=9 #1449

Open
@rhpvorderman

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;
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions