1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Prevent closing of innerstream of php://temp stream

Fixes GH-21221
Closes GH-21222
This commit is contained in:
Ilija Tovilo
2026-02-15 19:05:32 +01:00
parent 80b1ede843
commit 92ba1e4ea0
3 changed files with 17 additions and 0 deletions

2
NEWS
View File

@@ -139,6 +139,8 @@ PHP NEWS
. Fixed bug GH-20370 (User stream filters could violate typed property . Fixed bug GH-20370 (User stream filters could violate typed property
constraints). (alexandre-daubois) constraints). (alexandre-daubois)
. Allowed filtered streams to be casted as fd for select. (Jakub Zelenka) . Allowed filtered streams to be casted as fd for select. (Jakub Zelenka)
. Fixed bug GH-21221 (Prevent closing of innerstream of php://temp stream).
(ilutov)
- Zip: - Zip:
. Fixed ZipArchive callback being called after executor has shut down. . Fixed ZipArchive callback being called after executor has shut down.

View File

@@ -0,0 +1,14 @@
--TEST--
GH-21221: Prevent closing of innerstream of php://temp stream
--CREDITS--
chongwick
--FILE--
<?php
$f = fopen('php://temp', 'r+b');
$resources = get_resources();
fclose(end($resources));
?>
--EXPECTF--
Warning: fclose(): cannot close the provided stream, as it must not be manually closed in %s on line %d

View File

@@ -105,6 +105,7 @@ PHPAPI php_stream *php_stream_encloses(php_stream *enclosing, php_stream *enclos
php_stream *orig = enclosed->enclosing_stream; php_stream *orig = enclosed->enclosing_stream;
php_stream_auto_cleanup(enclosed); php_stream_auto_cleanup(enclosed);
enclosed->flags |= PHP_STREAM_FLAG_NO_FCLOSE;
enclosed->enclosing_stream = enclosing; enclosed->enclosing_stream = enclosing;
return orig; return orig;
} }