Skip to content

Commit dc73b73

Browse files
iluuu1994dstogovnielsdos
committed
Fix mis-compilation of by-reference nullsafe operator
Fixes oss-fuzz #60011 Closes GH-11540 Co-authored-by: Dmitry Stogov <dmitry@zend.com> Co-authored-by: Niels Dossche <7771979+nielsdos@users.noreply.github.com>
1 parent 3483229 commit dc73b73

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ PHP NEWS
88
- CLI:
99
. Fix interrupted CLI output causing the process to exit. (nielsdos)
1010

11+
- Core:
12+
. Fixed oss-fuzz #60011 (Mis-compilation of by-reference nullsafe operator).
13+
(ilutov)
14+
1115
- Date:
1216
. Fixed bug GH-11368 (Date modify returns invalid datetime). (Derick)
1317

Zend/tests/oss_fuzz_60011_1.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--TEST--
2+
oss-fuzz #60011 (Incorrect order of instruction with nullsafe operator)
3+
--FILE--
4+
<?php
5+
[&$y]=$y->y?->y;
6+
?>
7+
--EXPECTF--
8+
Fatal error: Cannot take reference of a nullsafe chain in %s on line %d

Zend/tests/oss_fuzz_60011_2.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--TEST--
2+
oss-fuzz #60011 (Incorrect order of instruction with nullsafe operator)
3+
--FILE--
4+
<?php
5+
[&$y]=$y?->y->y;
6+
?>
7+
--EXPECTF--
8+
Fatal error: Cannot take reference of a nullsafe chain in %s on line %d

Zend/zend_compile.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3257,6 +3257,9 @@ static void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */
32573257
if (!zend_is_variable_or_call(expr_ast)) {
32583258
zend_error_noreturn(E_COMPILE_ERROR,
32593259
"Cannot assign reference to non referenceable value");
3260+
} else if (zend_ast_is_short_circuited(expr_ast)) {
3261+
zend_error_noreturn(E_COMPILE_ERROR,
3262+
"Cannot take reference of a nullsafe chain");
32603263
}
32613264

32623265
zend_compile_var(&expr_node, expr_ast, BP_VAR_W, 1);

0 commit comments

Comments
 (0)