[php-src] PR #25617: Fix GH-25586: UAF in php_stream_cast() when stream_flush() closes the stream
| From: | lazerg | Date: | Fri, 20 Nov 2026 02:16:08 +0000 |
| Subject: | [php-src] PR #25617: Fix GH-25586: UAF in php_stream_cast() when stream_flush() closes the stream | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-40843@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25617
Author: lazerg
Fixes GH-25586
The GH-14506 fix set
PHP_STREAM_FLAG_NO_FCLOSE around most userspace stream handlers,
but not around stream_flush(). A stream_flush() that calls
fclose() on its own stream frees it, and callers like php_stream_cast()
(via proc_open()) and php_stream_seek() with a write filter keep using it
after the flush. This sets the flag in php_userstreamop_flush() too, so the
fclose() there only warns.
gh14506.phpt needed an update for the same reason: its fflush() call used
to close the stream from inside stream_flush(), now it warns and the stream stays open
until the final fclose().