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 Zend/Optimizer/zend_inference.c
Original file line number Diff line number Diff line change
Expand Up @@ -3849,7 +3849,7 @@ static zend_always_inline zend_result _zend_update_type_info(
tmp &= ~MAY_BE_RC1;
}
if (opline->opcode == ZEND_FETCH_STATIC_PROP_IS) {
tmp |= MAY_BE_UNDEF;
tmp |= MAY_BE_NULL;
}
}
UPDATE_SSA_TYPE(tmp, ssa_op->result_def);
Expand Down
17 changes: 17 additions & 0 deletions Zend/tests/gh20403.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
GH-20403 (Heap buffer overflow in zval_undefined_cv() when unsetting through an uninitialized typed static property)
--FILE--
<?php

class Test {
public static X $instances;
}

$test = new Test;
unset($test::$instances[$x]->x);

?>
===DONE===
--EXPECTF--
Warning: Undefined variable $x in %s on line %d
===DONE===
20 changes: 20 additions & 0 deletions Zend/tests/oss_fuzz_429429090.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
OSS-Fuzz #429429090: FETCH_OBJ_UNSET IS_UNDEF result
--FILE--
<?php

class C {
public D $x;
static D $y;
}

$c = new C();
isset($c->x[0]->prop);
unset($c->x[0]->prop);
isset(C::$y[0]->prop);
unset(C::$y[0]->prop);

?>
===DONE===
--EXPECT--
===DONE===
8 changes: 8 additions & 0 deletions Zend/zend_execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -3453,6 +3453,9 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
} else if (UNEXPECTED(Z_ISERROR_P(ptr))) {
ZVAL_ERROR(result);
goto end;
} else if (type == BP_VAR_UNSET && UNEXPECTED(Z_TYPE_P(ptr) == IS_UNDEF)) {
ZVAL_NULL(result);
goto end;
}

ZVAL_INDIRECT(result, ptr);
Expand Down Expand Up @@ -3603,6 +3606,11 @@ static zend_never_inline zend_result zend_fetch_static_property_address_ex(zval
return FAILURE;
}

if (UNEXPECTED(Z_TYPE_P(*retval) == IS_UNDEF)
&& (fetch_type == BP_VAR_IS || fetch_type == BP_VAR_UNSET)) {
return FAILURE;
}

*prop_info = property_info;

if (EXPECTED(op1_type == IS_CONST)
Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_vm_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -1839,7 +1839,7 @@ ZEND_VM_HELPER(zend_fetch_static_prop_helper, ANY, ANY, int type)
SAVE_OPLINE();

if (UNEXPECTED(zend_fetch_static_property_address(&prop, NULL, opline->extended_value & ~ZEND_FETCH_OBJ_FLAGS, type, opline->extended_value OPLINE_CC EXECUTE_DATA_CC) != SUCCESS)) {
ZEND_ASSERT(EG(exception) || (type == BP_VAR_IS));
ZEND_ASSERT(EG(exception) || (type == BP_VAR_IS) || (type == BP_VAR_UNSET));
prop = &EG(uninitialized_zval);
}

Expand Down
2 changes: 1 addition & 1 deletion Zend/zend_vm_execute.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading