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

From: Date: Sat, 24 Oct 2015 11:32:17 +0000
Subject: com php-src: Fix bug #70782: Zend/tests/bug70782.phpt Zend/zend_compile.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-89505@lists.php.net to get a copy of this message
Commit: 2e7290f046ecf01ad47707e774f5eb1c10ed63be Author: Nikita Popov <nikic@php.net> Sat, 24 Oct 2015 23:18:28 +0200 Committer: Anatol Belski <ab@php.net> Sat, 24 Oct 2015 13:32:17 +0200 Parents: 073e155f4ec1467087a5c8f4713be6fa3ae23495 Branches: PHP-7.0.0 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2e7290f046ecf01ad47707e774f5eb1c10ed63be Log: Fix bug #70782 Bugs: https://bugs.php.net/70782 Changed paths: A Zend/tests/bug70782.phpt M Zend/zend_compile.c Diff: 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 (#89505) next »