Skip to content

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

Closed
iliaal wants to merge 1 commit intomasterfrom
feat/stream-filter-max-output
Closed

zlib/bz2: add max_output filter param to cap decompression output#45
iliaal wants to merge 1 commit intomasterfrom
feat/stream-filter-max-output

Conversation

@iliaal
Copy link
Copy Markdown
Owner

@iliaal iliaal commented Apr 23, 2026

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.

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
Copy link
Copy Markdown
Owner Author

iliaal commented Apr 23, 2026

Superseded by php#21852.

@iliaal iliaal closed this Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant