com php-src: #72085: SEGV on unknown address zif_xml_parse : NEWS ext/xml/tests/bug72085.phpt ext/xml/ xml.c

From: Date: Tue, 16 Aug 2016 22:42:45 +0000
Subject: com php-src: #72085: SEGV on unknown address zif_xml_parse : NEWS ext/xml/tests/bug72085.phpt ext/xml/ xml.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-93814@lists.php.net to get a copy of this message
Commit: 1bb92d52121cf2635df163911216bf2958db4d34 Author: Christoph M. Becker <cmbecker69@gmx.de> Wed, 17 Aug 2016 00:41:31 +0200 Parents: 4a4422740f917f46e0860024667042733f61152b Branches: PHP-5.6 PHP-7..0 PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=1bb92d52121cf2635df163911216bf2958db4d34 Log: #72085: SEGV on unknown address zif_xml_parse We better make sure that the ZVALs we're accessing as arrays are indeed arrays. Bugs: https://bugs.php.net/72085 Changed paths: M NEWS A ext/xml/tests/bug72085.phpt M ext/xml/xml.c Diff: diff --git a/NEWS b/NEWS index bf6a294..30a17c1 100644 --- a/NEWS +++ b/NEWS @@ -25,6 +25,9 @@ PHP NEWS . Fixed bug #72823 (strtr out-of-bound access). (cmb) . Fixed bug #72278 (getimagesize returning FALSE on valid jpg). (cmb) +- XML: + . Fixed bug #72085 (SEGV on unknown address zif_xml_parse). (cmb) + 18 Aug 2016, PHP 5.6.25 - Core: diff --git a/ext/xml/tests/bug72085.phpt b/ext/xml/tests/bug72085.phpt new file mode 100644 index 0000000..2989289 --- /dev/null +++ b/ext/xml/tests/bug72085.phpt @@ -0,0 +1,74 @@ +--TEST-- +Bug #72085 (SEGV on unknown address zif_xml_parse) +--SKIPIF-- +<?php +if (!extension_loaded('xml')) die('skip xml extension not available'); +?> +--FILE-- +<?php +$var1 = xml_parser_create_ns(); +xml_set_element_handler($var1, new Exception(""), 4096); +xml_parse($var1, str_repeat("<a>", 10)); +?> +===DONE=== +--EXPECTF-- +Warning: Invalid callback exception 'Exception' in %s%ebug72085.php:%d +Stack trace: +#0 {main}, no array or string given in %s%ebug72085.php on line %d + +Warning: xml_parse(): Unable to call handler in %s%ebug72085.php on line %d + +Warning: Invalid callback exception 'Exception' in %s%ebug72085.php:%d +Stack trace: +#0 {main}, no array or string given in %s%ebug72085.php on line %d + +Warning: xml_parse(): Unable to call handler in %s%ebug72085.php on line %d + +Warning: Invalid callback exception 'Exception' in %s%ebug72085.php:%d +Stack trace: +#0 {main}, no array or string given in %s%ebug72085.php on line %d + +Warning: xml_parse(): Unable to call handler in %s%ebug72085.php on line %d + +Warning: Invalid callback exception 'Exception' in %s%ebug72085..php:%d +Stack trace: +#0 {main}, no array or string given in %s%ebug72085.php on line %d + +Warning: xml_parse(): Unable to call handler in %s%ebug72085.php on line %d + +Warning: Invalid callback exception 'Exception' in %s%ebug72085.php:%d +Stack trace: +#0 {main}, no array or string given in %s%ebug72085.php on line %d + +Warning: xml_parse(): Unable to call handler in %s%ebug72085.php on line %d + +Warning: Invalid callback exception 'Exception' in %s%ebug72085.php:%d +Stack trace: +#0 {main}, no array or string given in %s%ebug72085.php on line %d + +Warning: xml_parse(): Unable to call handler in %s%ebug72085.php on line %d + +Warning: Invalid callback exception 'Exception' in %s%ebug72085.php:%d +Stack trace: +#0 {main}, no array or string given in %s%ebug72085.php on line %d + +Warning: xml_parse(): Unable to call handler in %s%ebug72085.php on line %d + +Warning: Invalid callback exception 'Exception' in %s%ebug72085.php:%d +Stack trace: +#0 {main}, no array or string given in %s%ebug72085.php on line %d + +Warning: xml_parse(): Unable to call handler in %s%ebug72085.php on line %d + +Warning: Invalid callback exception 'Exception' in %s%ebug72085.php:%d +Stack trace: +#0 {main}, no array or string given in %s%ebug72085.php on line %d + +Warning: xml_parse(): Unable to call handler in %s%ebug72085.php on line %d + +Warning: Invalid callback exception 'Exception' in %s%ebug72085.php:%d +Stack trace: +#0 {main}, no array or string given in %s%ebug72085.php on line %d + +Warning: xml_parse(): Unable to call handler in %s%ebug72085.php on line %d +===DONE=== diff --git a/ext/xml/xml.c b/ext/xml/xml.c index 0850f0c..9eba47b 100644 --- a/ext/xml/xml.c +++ b/ext/xml/xml.c @@ -535,7 +535,8 @@ static zval *xml_call_handler(xml_parser *parser, zval *handler, zend_function * if (Z_TYPE_P(handler) == IS_STRING) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to call handler %s()", Z_STRVAL_P(handler)); - } else if (zend_hash_index_find(Z_ARRVAL_P(handler), 0, (void **) &obj) == SUCCESS && + } else if (Z_TYPE_P(handler) == IS_ARRAY && + zend_hash_index_find(Z_ARRVAL_P(handler), 0, (void **) &obj) == SUCCESS && zend_hash_index_find(Z_ARRVAL_P(handler), 1, (void **) &method) == SUCCESS && Z_TYPE_PP(obj) == IS_OBJECT && Z_TYPE_PP(method) == IS_STRING) {

« previous php.cvs (#93814) next »