File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1482,7 +1482,8 @@ PHP_METHOD(ArrayObject, __unserialize)
14821482 RETURN_THROWS ();
14831483 }
14841484
1485- if (!instanceof_function (ce , zend_ce_iterator )) {
1485+ if (!instanceof_function (ce , spl_ce_ArrayIterator ) &&
1486+ !instanceof_function (ce , spl_ce_RecursiveArrayIterator )) {
14861487 zend_throw_exception_ex (spl_ce_UnexpectedValueException , 0 ,
14871488 "Cannot deserialize ArrayObject with iterator class '%s'; this class does not implement the Iterator interface" ,
14881489 ZSTR_VAL (Z_STR_P (iterator_class_zv )));
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GH-22047: ArrayObject invalid iterator class in serialized payload
3+ --FILE--
4+ <?php
5+
6+ $ 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";} ' ;
7+
8+ try {
9+ $ obj = unserialize ($ payload );
10+ foreach ($ obj as $ k => $ v ) {
11+ echo "should not reach here \n" ;
12+ }
13+ } catch (UnexpectedValueException $ e ) {
14+ echo $ e ->getMessage (), "\n" ;
15+ }
16+
17+ ?>
18+ --EXPECTF--
19+ Cannot deserialize ArrayObject with iterator class 'GlobIterator'; this class does not implement the Iterator interface
You can’t perform that action at this time.
0 commit comments