summaryrefslogtreecommitdiff
path: root/ext/simplexml
diff options
context:
space:
mode:
authorRob Richards <rrichards@php.net>2004-03-01 12:09:24 +0000
committerRob Richards <rrichards@php.net>2004-03-01 12:09:24 +0000
commit76ee5707f76aeaefbe128b1cd0ea1d5521c860c7 (patch)
tree1506c10ed79407170b7b6ac039162dc65dc5a2bd /ext/simplexml
parent9f9151473c5a14c45faf4e2f804097ec83c9b00d (diff)
downloadphp-git-76ee5707f76aeaefbe128b1cd0ea1d5521c860c7.tar.gz
Fix bug #27436 dom_import_simplexml innaccurate
extensions register callbacks to export nodes prevents segfault passing invalid objects to import functions
Diffstat (limited to 'ext/simplexml')
-rw-r--r--ext/simplexml/simplexml.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c
index 6cc3e23e1e..f232c97c20 100644
--- a/ext/simplexml/simplexml.c
+++ b/ext/simplexml/simplexml.c
@@ -1490,6 +1490,16 @@ static void php_sxe_iterator_rewind(zend_object_iterator *iter TSRMLS_DC)
}
+void *simplexml_export_node(zval *object TSRMLS_DC)
+{
+ php_sxe_object *sxe;
+ xmlNodePtr node;
+
+ sxe = php_sxe_fetch_object(object TSRMLS_CC);
+ GET_NODE(sxe, node);
+ return php_sxe_get_first_node(sxe, node TSRMLS_CC);
+}
+
#ifdef HAVE_DOM
/* {{{ proto simplemxml_element simplexml_import_dom(domNode node [, string class_name])
Get a simplexml_element object from dom to allow for processing */
@@ -1509,8 +1519,9 @@ PHP_FUNCTION(simplexml_import_dom)
object = (php_libxml_node_object *)zend_object_store_get_object(node TSRMLS_CC);
- if (object->node && object->node->node) {
- nodep = object->node->node;
+ nodep = php_libxml_import_node(node TSRMLS_CC);
+
+ if (nodep) {
if (nodep->doc == NULL) {
php_error(E_WARNING, "Imported Node must have associated Document");
RETURN_NULL();
@@ -1603,6 +1614,8 @@ PHP_MINIT_FUNCTION(simplexml)
}
#endif /* HAVE_SPL */
+ php_libxml_register_export(sxe_class_entry, simplexml_export_node);
+
return SUCCESS;
}
/* }}} */