diff options
author | Aaron Piotrowski <aaron@trowski.com> | 2016-06-10 22:02:23 -0500 |
---|---|---|
committer | Aaron Piotrowski <aaron@trowski.com> | 2016-06-10 22:02:23 -0500 |
commit | e3c681aa5cc71122a8d2fae42e6513fc413ccac8 (patch) | |
tree | 5f1df62f7b666028edb0ee1adf083a52d63df45a /ext/simplexml | |
parent | fb4e3085cbaa76eb8f28eebf848a81d1c0190067 (diff) | |
parent | 792e89385ca6fc722a03590722eb7745a2374720 (diff) | |
download | php-git-e3c681aa5cc71122a8d2fae42e6513fc413ccac8.tar.gz |
Merge branch 'master' into throw-error-in-extensions
Diffstat (limited to 'ext/simplexml')
-rw-r--r-- | ext/simplexml/php_simplexml.h | 5 | ||||
-rw-r--r-- | ext/simplexml/php_simplexml_exports.h | 2 | ||||
-rw-r--r-- | ext/simplexml/simplexml.c | 49 | ||||
-rw-r--r-- | ext/simplexml/sxe.c | 2 | ||||
-rw-r--r-- | ext/simplexml/sxe.h | 2 | ||||
-rw-r--r-- | ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt | 9 | ||||
-rw-r--r-- | ext/simplexml/tests/bug66084_1.phpt | 2 |
7 files changed, 48 insertions, 23 deletions
diff --git a/ext/simplexml/php_simplexml.h b/ext/simplexml/php_simplexml.h index 1dec6796de..ea29f1399c 100644 --- a/ext/simplexml/php_simplexml.h +++ b/ext/simplexml/php_simplexml.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -45,9 +45,6 @@ extern zend_module_entry simplexml_module_entry; PHP_MINIT_FUNCTION(simplexml); PHP_MSHUTDOWN_FUNCTION(simplexml); -#ifdef HAVE_SPL -PHP_RINIT_FUNCTION(simplexml); -#endif PHP_MINFO_FUNCTION(simplexml); typedef enum { diff --git a/ext/simplexml/php_simplexml_exports.h b/ext/simplexml/php_simplexml_exports.h index 5fa156c850..8e09cb829a 100644 --- a/ext/simplexml/php_simplexml_exports.h +++ b/ext/simplexml/php_simplexml_exports.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index c047d7e235..d848fcac16 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -64,7 +64,7 @@ static void php_sxe_iterator_rewind(zend_object_iterator *iter); /* {{{ _node_as_zval() */ -static void _node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value, SXE_ITER itertype, char *name, const char *nsprefix, int isprefix) +static void _node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value, SXE_ITER itertype, char *name, const xmlChar *nsprefix, int isprefix) { php_sxe_object *subnode; @@ -76,7 +76,7 @@ static void _node_as_zval(php_sxe_object *sxe, xmlNodePtr node, zval *value, SXE subnode->iter.name = (xmlChar*)estrdup(name); } if (nsprefix && *nsprefix) { - subnode->iter.nsprefix = (xmlChar*)estrdup(nsprefix); + subnode->iter.nsprefix = (xmlChar*)estrdup((char*)nsprefix); subnode->iter.isprefix = isprefix; } @@ -978,7 +978,7 @@ static inline zend_string *sxe_xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr li /* {{{ _get_base_node_value() */ -static void _get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval *value, char *nsprefix, int isprefix) +static void _get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval *value, xmlChar *nsprefix, int isprefix) { php_sxe_object *subnode; xmlChar *contents; @@ -994,7 +994,7 @@ static void _get_base_node_value(php_sxe_object *sxe_ref, xmlNodePtr node, zval subnode->document = sxe_ref->document; subnode->document->refcount++; if (nsprefix && *nsprefix) { - subnode->iter.nsprefix = (xmlChar*)estrdup(nsprefix); + subnode->iter.nsprefix = (xmlChar*)estrdup((char *)nsprefix); subnode->iter.isprefix = isprefix; } php_libxml_increment_node_ptr((php_libxml_node_object *)subnode, node, NULL); @@ -1186,7 +1186,7 @@ static HashTable *sxe_get_prop_hash(zval *object, int is_debug) /* {{{ */ node = NULL; } else if (sxe->iter.type != SXE_ITER_CHILD) { - if ( sxe->iter.type == SXE_ITER_NONE || !node->children || !node->parent || node->children->next || node->children->children || node->parent->children == node->parent->last ) { + if ( sxe->iter.type == SXE_ITER_NONE || !node->children || !node->parent || !node->next || node->children->next || node->children->children || node->parent->children == node->parent->last ) { node = node->children; } else { ZVAL_COPY_VALUE(&iter_data, &sxe->iter.data); @@ -2206,7 +2206,12 @@ PHP_FUNCTION(simplexml_load_file) return; } - docp = xmlReadFile(filename, NULL, options); + if (ZEND_LONG_EXCEEDS_INT(options)) { + php_error_docref(NULL, E_WARNING, "Invalid options"); + RETURN_FALSE; + } + + docp = xmlReadFile(filename, NULL, (int)options); if (!docp) { RETURN_FALSE; @@ -2247,7 +2252,20 @@ PHP_FUNCTION(simplexml_load_string) return; } - docp = xmlReadMemory(data, data_len, NULL, NULL, options); + if (ZEND_SIZE_T_INT_OVFL(data_len)) { + php_error_docref(NULL, E_WARNING, "Data is too long"); + RETURN_FALSE; + } + if (ZEND_SIZE_T_INT_OVFL(ns_len)) { + php_error_docref(NULL, E_WARNING, "Namespace is too long"); + RETURN_FALSE; + } + if (ZEND_LONG_EXCEEDS_INT(options)) { + php_error_docref(NULL, E_WARNING, "Invalid options"); + RETURN_FALSE; + } + + docp = xmlReadMemory(data, (int)data_len, NULL, NULL, (int)options); if (!docp) { RETURN_FALSE; @@ -2284,7 +2302,20 @@ SXE_METHOD(__construct) return; } - docp = is_url ? xmlReadFile(data, NULL, options) : xmlReadMemory(data, data_len, NULL, NULL, options); + if (ZEND_SIZE_T_INT_OVFL(data_len)) { + php_error_docref(NULL, E_WARNING, "Data is too long"); + RETURN_FALSE; + } + if (ZEND_SIZE_T_INT_OVFL(ns_len)) { + php_error_docref(NULL, E_WARNING, "Namespace is too long"); + RETURN_FALSE; + } + if (ZEND_LONG_EXCEEDS_INT(options)) { + php_error_docref(NULL, E_WARNING, "Invalid options"); + RETURN_FALSE; + } + + docp = is_url ? xmlReadFile(data, NULL, (int)options) : xmlReadMemory(data, (int)data_len, NULL, NULL, (int)options); if (!docp) { ((php_libxml_node_object *)sxe)->document = NULL; diff --git a/ext/simplexml/sxe.c b/ext/simplexml/sxe.c index fc3f28d6d3..49a72a81e6 100644 --- a/ext/simplexml/sxe.c +++ b/ext/simplexml/sxe.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/simplexml/sxe.h b/ext/simplexml/sxe.h index 78967313d1..7c64ef9082 100644 --- a/ext/simplexml/sxe.h +++ b/ext/simplexml/sxe.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 7 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2015 The PHP Group | + | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt b/ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt index d4d709753f..75cf5720d5 100644 --- a/ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt +++ b/ext/simplexml/tests/SimpleXMLElement_xpath_4.phpt @@ -8,15 +8,10 @@ if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platforms only"); --FILE-- <?php $xml = simplexml_load_string("XXXXXXX^",$x,0x6000000000000001); -var_dump($xml->xpath("BBBB")); +var_dump($xml); ?> --EXPECTF-- Notice: Undefined variable: x in %s on line %d -Warning: simplexml_load_string(): Entity: line 1: parser error : Start tag expected, '<' not found in %s on line %d - -Warning: simplexml_load_string(): XXXXXXX^ in %s on line %d - -Warning: simplexml_load_string(): ^ in %s on line %d +Warning: simplexml_load_string(): Invalid options in %s on line %d bool(false) - diff --git a/ext/simplexml/tests/bug66084_1.phpt b/ext/simplexml/tests/bug66084_1.phpt index 80e91df7c6..85ab10ee59 100644 --- a/ext/simplexml/tests/bug66084_1.phpt +++ b/ext/simplexml/tests/bug66084_1.phpt @@ -5,12 +5,14 @@ Bug #66084 simplexml_load_string() mangles empty node name, json variant <?php if (!extension_loaded("json")) print "skip json not available"; ?> --FILE-- <?php +echo json_encode(simplexml_load_string('<a><b/><c><x/></c></a>')->c), "\n"; echo json_encode(simplexml_load_string('<a><b/><c><x/></c></a>')), "\n"; echo json_encode(simplexml_load_string('<a><b/><d/><c><x/></c></a>')), "\n"; echo json_encode(simplexml_load_string('<a><b/><c><d/><x/></c></a>')), "\n"; echo json_encode(simplexml_load_string('<a><b/><c><d><x/></d></c></a>')), "\n"; ?> --EXPECT-- +{"x":{}} {"b":{},"c":{"x":{}}} {"b":{},"d":{},"c":{"x":{}}} {"b":{},"c":{"d":{},"x":{}}} |