Skip to content

Commit 21562aa

Browse files
committed
Check for append to $GLOBALS
Fixes oss-fuzz #29389.
1 parent 3e01f5a commit 21562aa

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Cannot append to $GLOBALS
3+
--FILE--
4+
<?php
5+
6+
$GLOBALS[] = 1;
7+
8+
?>
9+
--EXPECTF--
10+
Fatal error: Cannot append to $GLOBALS in %s on line %d

Zend/zend_compile.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2773,6 +2773,10 @@ static zend_op *zend_delayed_compile_dim(znode *result, zend_ast *ast, uint32_t
27732773
znode var_node, dim_node;
27742774

27752775
if (is_globals_fetch(var_ast)) {
2776+
if (dim_ast == NULL) {
2777+
zend_error_noreturn(E_COMPILE_ERROR, "Cannot append to $GLOBALS");
2778+
}
2779+
27762780
zend_compile_expr(&dim_node, dim_ast);
27772781
if (dim_node.op_type == IS_CONST) {
27782782
convert_to_string(&dim_node.u.constant);

0 commit comments

Comments
 (0)