Skip to content
Merged
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
6 changes: 3 additions & 3 deletions ext/opcache/jit/zend_jit_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1718,7 +1718,7 @@ static void ZEND_FASTCALL zend_jit_fast_assign_concat_helper(zval *op1, zval *op
zend_string *result_str;
uint32_t flags = ZSTR_GET_COPYABLE_CONCAT_PROPERTIES_BOTH(Z_STR_P(op1), Z_STR_P(op2));

if (UNEXPECTED(op1_len > SIZE_MAX - op2_len)) {
if (UNEXPECTED(op1_len > ZSTR_MAX_LEN - op2_len)) {
zend_throw_error(NULL, "String size overflow");
return;
}
Expand Down Expand Up @@ -1754,7 +1754,7 @@ static void ZEND_FASTCALL zend_jit_fast_concat_helper(zval *result, zval *op1, z
zend_string *result_str;
uint32_t flags = ZSTR_GET_COPYABLE_CONCAT_PROPERTIES_BOTH(Z_STR_P(op1), Z_STR_P(op2));

if (UNEXPECTED(op1_len > SIZE_MAX - op2_len)) {
if (UNEXPECTED(op1_len > ZSTR_MAX_LEN - op2_len)) {
zend_throw_error(NULL, "String size overflow");
return;
}
Expand All @@ -1778,7 +1778,7 @@ static void ZEND_FASTCALL zend_jit_fast_concat_tmp_helper(zval *result, zval *op
zend_string *result_str;
uint32_t flags = ZSTR_GET_COPYABLE_CONCAT_PROPERTIES_BOTH(Z_STR_P(op1), Z_STR_P(op2));

if (UNEXPECTED(op1_len > SIZE_MAX - op2_len)) {
if (UNEXPECTED(op1_len > ZSTR_MAX_LEN - op2_len)) {
zend_throw_error(NULL, "String size overflow");
return;
}
Expand Down
1 change: 1 addition & 0 deletions ext/opcache/jit/zend_jit_ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -4213,6 +4213,7 @@ static int zend_jit_handler(zend_jit_ctx *jit, const zend_op *opline, int may_th
case ZEND_ASSIGN_STATIC_PROP_OP:
case ZEND_ASSIGN_STATIC_PROP_REF:
case ZEND_ASSIGN_OBJ_REF:
case ZEND_FRAMELESS_ICALL_3:
zend_jit_set_last_valid_opline(jit, opline + 2);
break;
default:
Expand Down
24 changes: 24 additions & 0 deletions ext/opcache/tests/jit/gh18037.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
--TEST--
GH-18037 (SEGV Zend/zend_execute.c)
--EXTENSIONS--
opcache
--INI--
opcache.jit=1201
--FILE--
<?php
function test_helper()
{
$list = [];
\in_array($list[0], $list, true) !== $list->matches();
}

test_helper();
?>
--EXPECTF--
Warning: Undefined array key 0 in %s on line %d

Fatal error: Uncaught Error: Call to a member function matches() on array in %s:%d
Stack trace:
#0 %s(%d): test_helper()
#1 {main}
thrown in %s on line %d
6 changes: 4 additions & 2 deletions ext/spl/spl_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,12 +665,14 @@ static bool spl_array_has_dimension_ex(bool check_inherited, zend_object *object
}
}

/* empty() check the value is not falsy, isset() only check it is not null */
bool result = check_empty ? zend_is_true(value) : Z_TYPE_P(value) != IS_NULL;

if (value == &rv) {
zval_ptr_dtor(&rv);
}

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

static int spl_array_has_dimension(zend_object *object, zval *offset, int check_empty) /* {{{ */
Expand Down
20 changes: 20 additions & 0 deletions ext/spl/tests/gh18018.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
GH-18018 (RC1 data returned from offsetGet causes UAF in ArrayObject)
--FILE--
<?php
class Crap extends ArrayObject
{
public function offsetGet($offset): mixed
{
return [random_int(1,1)];
}
}

$values = ['qux' => 1];

$object = new Crap($values);

var_dump(empty($object['qux']));
?>
--EXPECT--
bool(false)
Loading