com php-src: Fix bug #70782: NEWS Zend/tests/bug70782.phpt Zend/zend_compile.c

From: Date: Sat, 24 Oct 2015 21:19:02 +0000
Subject: com php-src: Fix bug #70782: NEWS Zend/tests/bug70782.phpt Zend/zend_compile.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-89494@lists.php.net to get a copy of this message
Commit: b9cc3176eb4211b01ab19554cbab490efc48d715 Author: Nikita Popov <nikic@php.net> Sat, 24 Oct 2015 23:18:28 +0200 Parents: aae108c1ce83ac60acd2fda18cf7e1351d6b49b9 Branches: PHP-7.0 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b9cc3176eb4211b01ab19554cbab490efc48d715 Log: Fix bug #70782 Bugs: https://bugs.php.net/70782 Changed paths: M NEWS A Zend/tests/bug70782.phpt M Zend/zend_compile.c Diff: diff --git a/NEWS b/NEWS index e39bd14..791ab30 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ PHP NEWS (Laruence) . Fixed bug #70689 (Exception handler does not work as expected). (Laruence) . Fixed bug #70430 (Stack buffer overflow in zend_language_parser()). (Nikita) + . Fixed bug #70782 (null ptr deref and segfault (zend_get_class_fetch_type)). + (Nikita) - Opcache: . Fixed bug #70724 (Undefined Symbols from opcache.so on Mac OS X 10.10). diff --git a/Zend/tests/bug70782.phpt b/Zend/tests/bug70782..phpt new file mode 100644 index 0000000..bbe63ff --- /dev/null +++ b/Zend/tests/bug70782.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #70782: null ptr deref and segfault (zend_get_class_fetch_type) +--FILE-- +<?php + +(-0)::$prop; + +?> +--EXPECTF-- +Fatal error: Illegal class name in %s on line %d diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 26655ad..c3e9384 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -2126,8 +2126,15 @@ static zend_op *zend_compile_class_ref(znode *result, zend_ast *name_ast, int th zend_compile_expr(&name_node, name_ast); if (name_node.op_type == IS_CONST) { - zend_string *name = Z_STR(name_node.u.constant); - uint32_t fetch_type = zend_get_class_fetch_type(name); + zend_string *name; + uint32_t fetch_type; + + if (Z_TYPE(name_node.u.constant) != IS_STRING) { + zend_error_noreturn(E_COMPILE_ERROR, "Illegal class name"); + } + + name = Z_STR(name_node.u.constant); + fetch_type = zend_get_class_fetch_type(name); opline = zend_emit_op(result, ZEND_FETCH_CLASS, NULL, NULL); opline->extended_value = fetch_type | (throw_exception ? ZEND_FETCH_CLASS_EXCEPTION : 0);

« previous php.cvs (#89494) next »