Merge branch 'PHP-7.3' into PHP-7.4

* PHP-7.3:
  Deny cloning of fileinfo objects
This commit is contained in:
Nikita Popov 2020-10-26 16:50:48 +01:00
commit 9353f11bd2
2 changed files with 28 additions and 0 deletions

View File

@ -218,6 +218,7 @@ PHP_MINIT_FUNCTION(finfo)
memcpy(&finfo_object_handlers, &std_object_handlers, sizeof(zend_object_handlers));
finfo_object_handlers.offset = XtOffsetOf(finfo_object, zo);
finfo_object_handlers.free_obj = finfo_objects_free;
finfo_object_handlers.clone_obj = NULL;
le_fileinfo = zend_register_list_destructors_ex(finfo_resource_destructor, NULL, "file_info", module_number);

View File

@ -0,0 +1,27 @@
--TEST--
Cloning and serializing finfo is not supported
--FILE--
<?php
$finfo = new finfo;
var_dump($finfo->buffer("Test string"));
try {
$finfo2 = clone $finfo;
var_dump($finfo2->buffer("Test string"));
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
try {
$finfo3 = unserialize(serialize($finfo));
var_dump($finfo3->buffer("Test string"));
} catch (Error $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECTF--
string(%d) "%s"
Trying to clone an uncloneable object of class finfo
Warning: finfo::buffer(): The invalid fileinfo object. in %s on line %d
bool(false)