Skip to content

Fix GH-25464: stream_filter_remove() + stale readbuflen on a read fil… - #25500

Closed
devnexen wants to merge 2 commits into
php:PHP-8.4from
devnexen:gh25464
Closed

devnexen wants to merge 2 commits into
php:PHP-8.4from
devnexen:gh25464

Conversation

@devnexen

Copy link
Copy Markdown
Member

…ter.

_php_stream_filter_flush() grew the read buffer without updating readbuflen, so the next fill computed readbuflen - writepos as a wrapped size and handed it to the read handler. Keep readbuflen in sync with the reallocated size.

…filter.

_php_stream_filter_flush() grew the read buffer without updating
readbuflen, so the next fill computed readbuflen - writepos as a wrapped
size and handed it to the read handler. Keep readbuflen in sync with the
reallocated size.
@devnexen
devnexen marked this pull request as ready for review November 16, 2026 22:20
@devnexen
devnexen requested a review from bukka as a code owner November 16, 2026 22:20
@iliaal

iliaal commented Nov 17, 2026

Copy link
Copy Markdown
Member

The test passes without the fix on a non-ASAN build: the over-read lands in the Zend MM heap and the loop still finishes. Asserting the data catches it everywhere, e.g. with mt_srand(1) data, collect the fgets() output and var_dump(str_ends_with($rest, substr($data, -8192))); (false before the fix, true after).

@iliaal iliaal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

g2g, thanks for the test change

@devnexen devnexen closed this in e726c94 Nov 24, 2026
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.

2 participants