mirror of
https://github.com/php/php-src.git
synced 2026-03-29 11:42:17 +02:00
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fix leak of invalid stream_read() return value
This commit is contained in:
24
ext/standard/tests/streams/stream_read_object_return.phpt
Normal file
24
ext/standard/tests/streams/stream_read_object_return.phpt
Normal file
@@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
Returning an object from stream_read() is invalid, but should not leak
|
||||
--FILE--
|
||||
<?php
|
||||
class MyStream {
|
||||
function stream_open() {
|
||||
return true;
|
||||
}
|
||||
function stream_stat() {
|
||||
return false;
|
||||
}
|
||||
function stream_read() {
|
||||
return new stdClass;
|
||||
}
|
||||
}
|
||||
stream_wrapper_register('mystream', MyStream::class);
|
||||
try {
|
||||
var_dump(file_get_contents('mystream://'));
|
||||
} catch (Error $e) {
|
||||
echo $e->getMessage(), "\n";
|
||||
}
|
||||
?>
|
||||
--EXPECT--
|
||||
Object of class stdClass could not be converted to string
|
||||
@@ -648,6 +648,7 @@ static ssize_t php_userstreamop_read(php_stream *stream, char *buf, size_t count
|
||||
}
|
||||
|
||||
if (!try_convert_to_string(&retval)) {
|
||||
zval_ptr_dtor(&retval);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user