Skip to content

Commit b9cc317

Browse files
committed
Fix bug #70782
1 parent aae108c commit b9cc317

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ PHP NEWS
77
(Laruence)
88
. Fixed bug #70689 (Exception handler does not work as expected). (Laruence)
99
. Fixed bug #70430 (Stack buffer overflow in zend_language_parser()). (Nikita)
10+
. Fixed bug #70782 (null ptr deref and segfault (zend_get_class_fetch_type)).
11+
(Nikita)
1012

1113
- Opcache:
1214
. Fixed bug #70724 (Undefined Symbols from opcache.so on Mac OS X 10.10).

Zend/tests/bug70782.phpt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Bug #70782: null ptr deref and segfault (zend_get_class_fetch_type)
3+
--FILE--
4+
<?php
5+
6+
(-0)::$prop;
7+
8+
?>
9+
--EXPECTF--
10+
Fatal error: Illegal class name in %s on line %d

Zend/zend_compile.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -2126,8 +2126,15 @@ static zend_op *zend_compile_class_ref(znode *result, zend_ast *name_ast, int th
21262126
zend_compile_expr(&name_node, name_ast);
21272127

21282128
if (name_node.op_type == IS_CONST) {
2129-
zend_string *name = Z_STR(name_node.u.constant);
2130-
uint32_t fetch_type = zend_get_class_fetch_type(name);
2129+
zend_string *name;
2130+
uint32_t fetch_type;
2131+
2132+
if (Z_TYPE(name_node.u.constant) != IS_STRING) {
2133+
zend_error_noreturn(E_COMPILE_ERROR, "Illegal class name");
2134+
}
2135+
2136+
name = Z_STR(name_node.u.constant);
2137+
fetch_type = zend_get_class_fetch_type(name);
21312138

21322139
opline = zend_emit_op(result, ZEND_FETCH_CLASS, NULL, NULL);
21332140
opline->extended_value = fetch_type | (throw_exception ? ZEND_FETCH_CLASS_EXCEPTION : 0);

0 commit comments

Comments
 (0)