Skip to content

Commit fc047b4

Browse files
committed
Merge branch 'PHP-8.4'
* PHP-8.4: [ci skip] Fix NEWS order Fix phpGH-18018: RC1 data returned from offsetGet causes UAF in ArrayObject
2 parents 11ec2cb + 3c17d3f commit fc047b4

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

ext/spl/spl_array.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,12 +665,14 @@ static bool spl_array_has_dimension_ex(bool check_inherited, zend_object *object
665665
}
666666
}
667667

668+
/* empty() check the value is not falsy, isset() only check it is not null */
669+
bool result = check_empty ? zend_is_true(value) : Z_TYPE_P(value) != IS_NULL;
670+
668671
if (value == &rv) {
669672
zval_ptr_dtor(&rv);
670673
}
671674

672-
/* empty() check the value is not falsy, isset() only check it is not null */
673-
return check_empty ? zend_is_true(value) : Z_TYPE_P(value) != IS_NULL;
675+
return result;
674676
} /* }}} */
675677

676678
static int spl_array_has_dimension(zend_object *object, zval *offset, int check_empty) /* {{{ */

ext/spl/tests/gh18018.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
GH-18018 (RC1 data returned from offsetGet causes UAF in ArrayObject)
3+
--FILE--
4+
<?php
5+
class Crap extends ArrayObject
6+
{
7+
public function offsetGet($offset): mixed
8+
{
9+
return [random_int(1,1)];
10+
}
11+
}
12+
13+
$values = ['qux' => 1];
14+
15+
$object = new Crap($values);
16+
17+
var_dump(empty($object['qux']));
18+
?>
19+
--EXPECT--
20+
bool(false)

0 commit comments

Comments
 (0)