mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix GH-9186 @strict-properties can be bypassed using unserialization (#9354)
* Emit deprecation warnings when adding dynamic properties to classes during unserialization - this will become an Error in php 9.0. (Adding dynamic properties in other contexts was already a deprecation warning - the use case of unserialization was overlooked) * Throw an error when attempting to add a dynamic property to a `readonly` class when unserializing * Add new serialization methods `__serialize`/`__unserialize` for SplFixedArray to avoid creating deprecated dynamic properties that would then be added to the backing fixed-size array * Don't add named dynamic/declared properties (e.g. $obj->foo) of SplFixedArray to the backing array when unserializing * Update tests to declare properties or to expect the deprecation warning * Add news entry Co-authored-by: Tyson Andre <tysonandre775@hotmail.com>
This commit is contained in:
parent
8d78dce902
commit
adb45a63c0
36 changed files with 271 additions and 22 deletions
|
@ -1740,6 +1740,9 @@ PHP_METHOD(ArrayObject, __unserialize)
|
|||
}
|
||||
|
||||
object_properties_load(&intern->std, Z_ARRVAL_P(members_zv));
|
||||
if (EG(exception)) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
if (iterator_class_zv && Z_TYPE_P(iterator_class_zv) == IS_STRING) {
|
||||
zend_class_entry *ce = zend_lookup_class(Z_STR_P(iterator_class_zv));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue