Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/spl/spl_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -1482,7 +1482,7 @@ PHP_METHOD(ArrayObject, __unserialize)
RETURN_THROWS();
}

if (!instanceof_function(ce, zend_ce_iterator)) {
if (!instanceof_function(ce, spl_ce_ArrayIterator)) {
zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0,
"Cannot deserialize ArrayObject with iterator class '%s'; this class does not implement the Iterator interface",
ZSTR_VAL(Z_STR_P(iterator_class_zv)));
Expand Down
19 changes: 19 additions & 0 deletions ext/spl/tests/GH-22047.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
GH-22047: ArrayObject invalid iterator class in serialized payload
--FILE--
<?php

$payload = 'O:11:"ArrayObject":4:{i:0;i:0;i:1;a:2:{i:4;d:0.0;i:1;b:1;}i:2;a:0:{}i:3;s:12:"GlobIterator";}';

try {
$obj = unserialize($payload);
foreach ($obj as $k => $v) {
echo "should not reach here\n";
}
} catch (UnexpectedValueException $e) {
echo $e->getMessage(), "\n";
}

?>
--EXPECTF--
Cannot deserialize ArrayObject with iterator class 'GlobIterator'; this class does not implement the Iterator interface
Loading