Skip to content

Commit 7a01c44

Browse files
committed
Fixed bug #69905 (null ptr deref and segfault in ZEND_FETCH_DIM_RW_SPEC_VAR_UNUSED_HANDLER)
1 parent 36d39b7 commit 7a01c44

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

Zend/tests/bug69905.phpt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Bug #69905 (null ptr deref and segfault in ZEND_FETCH_DIM_RW_SPEC_VAR_UNUSED_HANDLER)
3+
--FILE--
4+
<?php
5+
md5(0)[]--;
6+
?>
7+
--EXPECTF--
8+
Fatal error: Uncaught Error: [] operator not supported for strings in %sbug69905.php:2
9+
Stack trace:
10+
#0 {main}
11+
thrown in %sbug69905.php on line 2

Zend/zend_execute.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1682,11 +1682,11 @@ static zend_always_inline void zend_fetch_dimension_address(zval *result, zval *
16821682

16831683
if (dim == NULL) {
16841684
zend_error(E_EXCEPTION | E_ERROR, "[] operator not supported for strings");
1685+
ZVAL_NULL(result);
16851686
} else {
16861687
zend_check_string_offset(dim, type);
1688+
ZVAL_INDIRECT(result, NULL); /* wrong string offset */
16871689
}
1688-
1689-
ZVAL_INDIRECT(result, NULL); /* wrong string offset */
16901690
} else if (EXPECTED(Z_TYPE_P(container) == IS_OBJECT)) {
16911691
if (!Z_OBJ_HT_P(container)->read_dimension) {
16921692
zend_error(E_EXCEPTION | E_ERROR, "Cannot use object as array");

0 commit comments

Comments
 (0)