Skip to content

Discard buckets abandoned by a filter that returns no output - #23564

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/filter-brigade-drain-84
Open

Discard buckets abandoned by a filter that returns no output#23564
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/filter-brigade-drain-84

Conversation

@iliaal

@iliaal iliaal commented Sep 4, 2026

Copy link
Copy Markdown
Member

A user filter can append buckets to its $out brigade and still answer PSFS_FEED_ME or PSFS_ERR_FATAL. Both brigades live on the caller's stack frame, so whatever is left on them when the caller returns leaks with bucket->brigade dangling, and re-appending such a bucket later writes through that pointer. php_stream_fill_read_buffer() and php_stream_filter_append_ex() already discard leftovers; _php_stream_filter_flush() returned without touching either brigade, and _php_stream_write_filtered() drained only the input one. Smallest case is a filter that appends one bucket to $out, returns PSFS_ERR_FATAL, and is then passed to stream_filter_remove().

@iliaal
iliaal requested a review from bukka as a code owner September 4, 2026 12:14
A user filter can append to its $out brigade and still answer PSFS_FEED_ME
or PSFS_ERR_FATAL. _php_stream_filter_flush() returned without touching
either brigade, and _php_stream_write_filtered() drained only brig_inp, so
those buckets leaked with bucket->brigade still pointing at the caller's
stack frame; re-appending such a bucket later writes through it.
php_stream_fill_read_buffer() and php_stream_filter_append_ex() already
discard them.

Closes phpGH-23564
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