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

Fix shm corruption with coercion in options of unserialize()

Closes GH-20129.
This commit is contained in:
Niels Dossche
2025-10-10 23:22:54 +02:00
parent 5a7c84f274
commit 88f8c5c0bb
3 changed files with 15 additions and 3 deletions

3
NEWS
View File

@@ -41,6 +41,9 @@ PHP NEWS
. Partially fixed bug GH-16317 (SimpleXML does not allow __debugInfo() overrides
to work). (nielsdos)
- Standard:
. Fix shm corruption with coercion in options of unserialize(). (nielsdos)
- XMLReader:
. Fix arginfo/zpp violations when LIBXML_SCHEMAS_ENABLED is not available.
(nielsdos)

View File

@@ -0,0 +1,8 @@
--TEST--
Shm corruption with coercion in options of unserialize()
--FILE--
<?php
unserialize("{}", ["allowed_classes" => [0]]);
?>
--EXPECTF--
Warning: unserialize(): Error at offset 0 of 2 bytes in %s on line %d

View File

@@ -1366,13 +1366,14 @@ PHPAPI void php_unserialize_with_options(zval *return_value, const char *buf, co
}
if(class_hash && Z_TYPE_P(classes) == IS_ARRAY) {
zval *entry;
zend_string *lcname;
zend_string *lcname, *tmp_str, *str;
ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(classes), entry) {
convert_to_string(entry);
lcname = zend_string_tolower(Z_STR_P(entry));
str = zval_get_tmp_string(entry, &tmp_str);
lcname = zend_string_tolower(str);
zend_hash_add_empty_element(class_hash, lcname);
zend_string_release_ex(lcname, 0);
zend_tmp_string_release(tmp_str);
} ZEND_HASH_FOREACH_END();
/* Exception during string conversion. */