mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
random: Validate that the arrays do not contain extra elements when unserializing (#9458)
* Apply `var_dump()` in 02_engine/all_serialize_error.phpt This ensures that an undetected serialization error is clear identifiable in the output. * random: Validate that the arrays do not contain extra elements when unserializing
This commit is contained in:
parent
15405c60da
commit
ddf7a5d4d9
5 changed files with 51 additions and 8 deletions
|
@ -272,6 +272,12 @@ PHP_METHOD(Random_Randomizer, __unserialize)
|
|||
Z_PARAM_ARRAY_HT(d);
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
/* Verify the expected number of elements, this implicitly ensures that no additional elements are present. */
|
||||
if (zend_hash_num_elements(d) != 1) {
|
||||
zend_throw_exception(NULL, "Invalid serialization data for Random\\Randomizer object", 0);
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
members_zv = zend_hash_index_find(d, 0);
|
||||
if (!members_zv || Z_TYPE_P(members_zv) != IS_ARRAY) {
|
||||
zend_throw_exception(NULL, "Invalid serialization data for Random\\Randomizer object", 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue