Skip to content

zlib/bz2: add max_output filter param to cap decompression output - #21852

Open
iliaal wants to merge 1 commit into
php:masterfrom
iliaal:feat/stream-filter-max-output
Open

iliaal wants to merge 1 commit into
php:masterfrom
iliaal:feat/stream-filter-max-output

Conversation

@iliaal

@iliaal iliaal commented Apr 23, 2026

Copy link
Copy Markdown
Member

Adds max_output to zlib.inflate and bzip2.decompress. When set, the filter tracks emitted bytes; once the cap is exceeded, the current bucket is dropped and the filter returns PSFS_ERR_FATAL, halting decompression mid-stream rather than after the full payload lands on the sink.

Opt-in on both filters. Omitting the key keeps existing behavior for every current caller. From userland: stream_filter_append($stream, 'zlib.inflate', STREAM_FILTER_WRITE, ['max_output' => N]).

A follow-up PR will wire this into phar so crafted archives with inflated uncompressed_filesize fail during streaming.

Comment thread ext/bz2/bz2_filter.c Resolved
Comment thread ext/zlib/zlib_filter.c Resolved
@iliaal
iliaal force-pushed the feat/stream-filter-max-output branch from 248d688 to af57e75 Compare April 24, 2026 10:05
@iliaal
iliaal requested a review from LamentXU123 April 24, 2026 10:12
@iliaal
iliaal force-pushed the feat/stream-filter-max-output branch from af57e75 to ae11615 Compare April 27, 2026 10:40
@bukka

bukka commented Nov 7, 2026

Copy link
Copy Markdown
Member

This needs to resolve conflicts

Optional max_output parameter on zlib.inflate and bzip2.decompress
caps bytes emitted by the filter. When the instance has a cap set and
exceeds it, the current bucket is dropped and the filter returns
PSFS_ERR_FATAL, stopping decompression amplification mid-stream
instead of after the full payload lands on the sink.

The parameter is opt-in. Omitting it preserves existing behavior for
all current callers. Userland opts in via
stream_filter_append($stream, 'zlib.inflate', STREAM_FILTER_WRITE,
['max_output' => N]).
@iliaal
iliaal force-pushed the feat/stream-filter-max-output branch from ae11615 to 0bdcd70 Compare November 7, 2026 13:27
@iliaal

iliaal commented Nov 7, 2026

Copy link
Copy Markdown
Member Author

Rebased.

@iliaal
iliaal requested review from bukka and ndossche November 7, 2026 13:28
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.

3 participants