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:
2
NEWS
2
NEWS
@@ -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.
|
||||||
|
|||||||
14
ext/standard/tests/gh21221.phpt
Normal file
14
ext/standard/tests/gh21221.phpt
Normal 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
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user