We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 9ee6078 + 9d39ff7 commit 52c7c74Copy full SHA for 52c7c74
NEWS
@@ -2,6 +2,10 @@ PHP NEWS
2
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3
?? ??? ????, PHP 8.4.2
4
5
+- DOM:
6
+ . Fixed bug GH-16906 (Reloading document can cause UAF in iterator).
7
+ (nielsdos)
8
+
9
- Opcache:
10
. Fixed bug GH-16851 (JIT_G(enabled) not set correctly on other threads).
11
(dktapps)
ext/dom/php_dom.c
@@ -1469,6 +1469,10 @@ void dom_namednode_iter(dom_object *basenode, int ntype, dom_object *intern, xml
1469
mapptr->baseobj = basenode;
1470
mapptr->nodetype = ntype;
1471
mapptr->ht = ht;
1472
+ if (EXPECTED(doc != NULL)) {
1473
+ mapptr->dict = doc->dict;
1474
+ xmlDictReference(doc->dict);
1475
+ }
1476
1477
const xmlChar* tmp;
1478
@@ -1582,6 +1586,7 @@ void dom_nnodemap_objects_free_storage(zend_object *object) /* {{{ */
1582
1586
if (!Z_ISUNDEF(objmap->baseobj_zv)) {
1583
1587
zval_ptr_dtor(&objmap->baseobj_zv);
1584
1588
}
1589
+ xmlDictFree(objmap->dict);
1585
1590
efree(objmap);
1591
intern->ptr = NULL;
1592
@@ -1613,6 +1618,7 @@ zend_object *dom_nnodemap_objects_new(zend_class_entry *class_type)
1613
1618
objmap->cached_length = -1;
1614
1619
objmap->cached_obj = NULL;
1615
1620
objmap->cached_obj_index = 0;
1621
+ objmap->dict = NULL;
1616
1622
1617
1623
return &intern->std;
1624
ext/dom/php_dom.h
@@ -88,6 +88,7 @@ typedef struct dom_nnodemap_object {
88
php_libxml_cache_tag cache_tag;
89
dom_object *cached_obj;
90
zend_long cached_obj_index;
91
+ xmlDictPtr dict;
92
bool free_local : 1;
93
bool free_ns : 1;
94
} dom_nnodemap_object;
ext/dom/tests/gh16906.phpt
@@ -0,0 +1,17 @@
1
+--TEST--
+GH-16906 (Reloading document can cause UAF in iterator)
+--EXTENSIONS--
+dom
+--FILE--
+<?php
+$doc = new DOMDocument;
+$doc->loadXML('<?xml version="1.0"?><span><strong id="1"/><strong id="2"/></span>');
+$list = $doc->getElementsByTagName('strong');
+$doc->load(__DIR__."/book.xml");
+var_dump($list);
12
+?>
13
+--EXPECT--
14
+object(DOMNodeList)#2 (1) {
15
+ ["length"]=>
16
+ int(0)
17
+}
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments