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

Merge branch 'PHP-8.3' into PHP-8.4

* PHP-8.3:
  Fix GH-16588: UAF in Observer->serialize
This commit is contained in:
Niels Dossche
2024-10-25 23:00:46 +02:00
3 changed files with 33 additions and 1 deletions

3
NEWS
View File

@@ -14,6 +14,9 @@ PHP NEWS
. Fixed bug GH-16167 (Prevent mixing PDO sub-classes with different DSN).
(kocsismate)
- SPL:
. Fixed bug GH-16588 (UAF in Observer->serialize). (nielsdos)
24 Oct 2024, PHP 8.4.0RC3
- Cli:

View File

@@ -833,11 +833,18 @@ PHP_METHOD(SplObjectStorage, serialize)
RETURN_NULL();
}
ZVAL_OBJ(&obj, element->obj);
/* Protect against modification; we need a full copy because the data may be refcounted. */
zval inf_copy;
ZVAL_COPY(&inf_copy, &element->inf);
php_var_serialize(&buf, &obj, &var_hash);
smart_str_appendc(&buf, ',');
php_var_serialize(&buf, &element->inf, &var_hash);
php_var_serialize(&buf, &inf_copy, &var_hash);
smart_str_appendc(&buf, ';');
zend_hash_move_forward_ex(&intern->storage, &pos);
zval_ptr_dtor(&inf_copy);
}
/* members */

View File

@@ -0,0 +1,22 @@
--TEST--
GH-16588 (UAF in Observer->serialize)
--CREDITS--
chibinz
--FILE--
<?php
class C {
function __serialize(): array {
global $store;
$store->removeAll($store);
return [];
}
}
$store = new SplObjectStorage;
$store[new C] = new stdClass;
var_dump($store->serialize());
?>
--EXPECT--
string(47) "x:i:1;O:1:"C":0:{},O:8:"stdClass":0:{};m:a:0:{}"