[php-src] PR #25822: Fix GH-25815: UAF when a userspace stream_stat() closes the stream
| From: | lazerg | Date: | Fri, 27 Nov 2026 07:56:32 +0000 |
| Subject: | [php-src] PR #25822: Fix GH-25815: UAF when a userspace stream_stat() closes the stream | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-41095@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/25822
Author: lazerg
Fixes GH-25815
php_userstreamop_stat() was the one handler left without the
PHP_STREAM_FLAG_NO_FCLOSE guard after GH-14506 and GH-25586. A
stream_stat() that calls fclose() on its own stream frees it, and callers
that stat the stream internally keep using it afterwards, e.g. stream_get_contents()
reads from the freed stream in _php_stream_copy_to_mem(). This sets the flag around the
call the same way the other handlers do, so the fclose() only warns.