[php-src] PR #25966: Fix GH-25959: "consumed" stream filter loses or repeats data
| From: | ArtUkrainskiy | Date: | Mon, 30 Nov 2026 17:45:05 +0000 |
| Subject: | [php-src] PR #25966: Fix GH-25959: "consumed" stream filter loses or repeats data | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-41274@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25966
Author: ArtUkrainskiy
Fixes GH-25959
On its final flush,
consumed_filter_filter() seeks the stream it's attached to.
That happens when a read reaches the end of the stream, or on stream_filter_remove().
In 8.4 and 8.5 the data is lost. stream_get_contents() on a file through the filter
returns an empty string, and fgets() returns no lines. Since 8.6 the seek is rejected
with a warning. When the first chunk already ends the stream, the seek goes to the start, and the
data comes back twice. With two consumed filters that read never ends.
The seek has been there since the filter was added in 2006, and the filter has no tests or docs. I
couldn't find a case where the seek does something useful, so this removes it. The filter now
passes the data through unchanged.
The test fails without the fix on 8.4 and on 8.6. Stream, filter and file tests pass on 8.4 and 8.6,
and the test passes with ASan and ZTS. The code change applies cleanly to 8.5, 8.6 and master.