Skip to content

ext/zlib: honor preset dictionary for raw inflate with non-default window#22381

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:zlib-raw-dict-window
Open

ext/zlib: honor preset dictionary for raw inflate with non-default window#22381
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:zlib-raw-dict-window

Conversation

@iliaal

@iliaal iliaal commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

inflate_init() applies a preset dictionary eagerly for raw streams, gated on encoding == PHP_ZLIB_ENCODING_RAW, but encoding is first adjusted by the window size (encoding += 15 - window), so a raw stream with a non-default window no longer matches and the dictionary is silently dropped. Raw streams carry no header and never emit Z_NEED_DICT, so the deferred application in inflate_add() never runs either. Gate on the pre-adjustment encoding; the deflate side already applies the dictionary unconditionally, so the roundtrip was broken for this case.

…ndow

inflate_init() applies the preset dictionary eagerly for raw streams via
inflateSetDictionary(), gated on encoding == PHP_ZLIB_ENCODING_RAW. But
encoding is first adjusted by the window size (encoding += 15 - window),
so a raw stream with a non-default window no longer equals
PHP_ZLIB_ENCODING_RAW and the dictionary is silently dropped; raw streams
carry no header and never emit Z_NEED_DICT, so inflate_add()'s deferred
path never applies it either. Gate on the pre-adjustment encoding. The
deflate side already applies the dictionary unconditionally, so the
roundtrip was broken for this case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant