diff --git a/NEWS b/NEWS index 7d90a01f51d..9b8840c39cd 100644 --- a/NEWS +++ b/NEWS @@ -15,6 +15,7 @@ PHP NEWS . Fix OSS-Fuzz #438780145 (Nested finally with repeated return type check may uaf). (ilutov) . Fixed bug GH-20905 (Lazy proxy bailing __clone assertion). (ilutov) + . Fixed bug GH-20479 (Hooked object properties overflow). (ndossche) - Date: . Update timelib to 2022.16. (Derick) diff --git a/Zend/tests/property_hooks/gh20479.phpt b/Zend/tests/property_hooks/gh20479.phpt new file mode 100644 index 00000000000..c53c4e4240c --- /dev/null +++ b/Zend/tests/property_hooks/gh20479.phpt @@ -0,0 +1,40 @@ +--TEST-- +GH-20479: Hooked object properties overflow +--CREDITS-- +Viet Hoang Luu (@vi3tL0u1s) +--FILE-- +g = $obj->h = 'x'; +var_export($obj); + +?> +--EXPECT-- +\Trigger::__set_state(array( + 'a' => 'x', + 'b' => 'x', + 'c' => 'x', + 'd' => 'x', + 'e' => 'x', + 'f' => 'x', + 'trigger' => 'trigger', + 'h' => 'x', + 'g' => 'x', +)) diff --git a/Zend/zend_property_hooks.c b/Zend/zend_property_hooks.c index 01a8afb1693..57e22f23ad7 100644 --- a/Zend/zend_property_hooks.c +++ b/Zend/zend_property_hooks.c @@ -121,7 +121,7 @@ skip_property: if (Z_TYPE_P(prop_value) == IS_INDIRECT) { continue; } - zval *tmp = _zend_hash_append(properties, prop_name, prop_value); + zval *tmp = zend_hash_add_new(properties, prop_name, prop_value); Z_TRY_ADDREF_P(tmp); } ZEND_HASH_FOREACH_END(); }