[php-src] master: Merge branch 'PHP-8.6'

From: Date: Wed, 28 Oct 2026 03:18:48 +0000
Subject: [php-src] master: Merge branch 'PHP-8.6'
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-142867@lists.php.net to get a copy of this message
Author: David Carlier (devnexen) Date: 2026-10-28T03:15:23Z Commit: https://github.com/php/php-src/commit/758c9ac5492848a54f9fd88fac2a54d5e6108c05 Raw diff: https://github.com/php/php-src/commit/758c9ac5492848a54f9fd88fac2a54d5e6108c05.diff Merge branch 'PHP-8.6' * PHP-8.6: ext/dom: fix UAF on namespace axis results with foreign-doc XPath callback nodes Changed paths: A ext/dom/tests/xpath_php_function_foreign_doc_namespace_axis.phpt M ext/dom/xpath.c Diff: diff --git a/ext/dom/tests/xpath_php_function_foreign_doc_namespace_axis.phpt b/ext/dom/tests/xpath_php_function_foreign_doc_namespace_axis.phpt new file mode 100644 index 000000000000..ad77a052d454 --- /dev/null +++ b/ext/dom/tests/xpath_php_function_foreign_doc_namespace_axis.phpt @@ -0,0 +1,36 @@ +--TEST-- +DOMXPath: namespace axis result on a node from a document created inside an XPath callback +--EXTENSIONS-- +dom +--FILE-- +<?php + +$doc = new DOMDocument; +$doc->loadXML('<root/>'); + +$xp = new DOMXPath($doc); +$xp->registerNamespace('my', 'my.ns'); +$xp->registerPHPFunctionNS('my.ns', 'include', function () { + $d = new DOMDocument; + $d->loadXML('<r><uaf xmlns:a="urn:a"/></r>'); + return $d->documentElement; +}); + +$result = $xp->query('my:include()/uaf/namespace::*'); +var_dump($result->length); +unset($xp); + +foreach ($result as $ns) { + var_dump($ns->nodeName, $ns->parentNode->nodeName); +} + +echo "Done\n"; + +?> +--EXPECT-- +int(2) +string(9) "xmlns:xml" +string(3) "uaf" +string(7) "xmlns:a" +string(3) "uaf" +Done diff --git a/ext/dom/xpath.c b/ext/dom/xpath.c index 892a64bbe79f..e3c5e48f6cd5 100644 --- a/ext/dom/xpath.c +++ b/ext/dom/xpath.c @@ -399,7 +399,7 @@ static void php_xpath_eval(INTERNAL_FUNCTION_PARAMETERS, int type, bool modern) /* Make sure parent dom object exists, so we can take an extra reference. */ zval parent_zval; /* don't destroy me, my lifetime is transferred to the fake namespace decl */ - php_dom_create_object(nsparent, &parent_zval, &intern->dom); + php_dom_create_object(nsparent, &parent_zval, dom_xpath_intern_for_doc(intern, nsparent->doc)); dom_object *parent_intern = Z_DOMOBJ_P(&parent_zval); node = php_dom_create_fake_namespace_decl(nsparent, original, &child, parent_intern);

« previous php.cvs (#142867) next »