File tree 4 files changed +58
-0
lines changed
4 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,10 @@ PHP NEWS
15
15
- Curl:
16
16
. Fixed bug GH-16802 (open_basedir bypass using curl extension). (nielsdos)
17
17
18
+ - DOM:
19
+ . Fixed bug GH-16777 (Calling the constructor again on a DOM object after it
20
+ is in a document causes UAF). (nielsdos)
21
+
18
22
- FPM:
19
23
. Fixed GH-16432 (PHP-FPM 8.2 SIGSEGV in fpm_get_status). (Jakub Zelenka)
20
24
Original file line number Diff line number Diff line change @@ -1024,6 +1024,7 @@ PHP_METHOD(DOMNode, insertBefore)
1024
1024
}
1025
1025
1026
1026
if (child -> doc == NULL && parentp -> doc != NULL ) {
1027
+ xmlSetTreeDoc (child , parentp -> doc );
1027
1028
dom_set_document_ref_pointers (child , intern -> document );
1028
1029
}
1029
1030
@@ -1188,6 +1189,7 @@ PHP_METHOD(DOMNode, replaceChild)
1188
1189
}
1189
1190
1190
1191
if (newchild -> doc == NULL && nodep -> doc != NULL ) {
1192
+ xmlSetTreeDoc (newchild , nodep -> doc );
1191
1193
dom_set_document_ref_pointers (newchild , intern -> document );
1192
1194
}
1193
1195
@@ -1291,6 +1293,7 @@ PHP_METHOD(DOMNode, appendChild)
1291
1293
}
1292
1294
1293
1295
if (child -> doc == NULL && nodep -> doc != NULL ) {
1296
+ xmlSetTreeDoc (child , nodep -> doc );
1294
1297
dom_set_document_ref_pointers (child , intern -> document );
1295
1298
}
1296
1299
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-16777 (Calling the constructor again on a DOM object after it is in a document causes UAF)
3
+ --EXTENSIONS--
4
+ dom
5
+ --FILE--
6
+ <?php
7
+ $ text = new DOMText ('my value ' );
8
+ $ doc = new DOMDocument ();
9
+ $ doc ->appendChild ($ text );
10
+ $ text ->__construct ('my new value ' );
11
+ $ doc ->appendChild ($ text );
12
+ echo $ doc ->saveXML ();
13
+ $ dom2 = new DOMDocument ();
14
+ try {
15
+ $ dom2 ->appendChild ($ text );
16
+ } catch (DOMException $ e ) {
17
+ echo $ e ->getMessage (), "\n" ;
18
+ }
19
+ ?>
20
+ --EXPECT--
21
+ <? xml version="1.0 "?>
22
+ my value
23
+ my new value
24
+ Wrong Document Error
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ GH-16777 (Calling the constructor again on a DOM object after it is in a document causes UAF)
3
+ --EXTENSIONS--
4
+ dom
5
+ --FILE--
6
+ <?php
7
+ $ el = new DOMElement ('name ' );
8
+ $ el ->append ($ child = new DOMElement ('child ' ));
9
+ $ doc = new DOMDocument ();
10
+ $ doc ->appendChild ($ el );
11
+ $ el ->__construct ('newname ' );
12
+ $ doc ->appendChild ($ el );
13
+ echo $ doc ->saveXML ();
14
+ $ dom2 = new DOMDocument ();
15
+ try {
16
+ $ dom2 ->appendChild ($ el );
17
+ } catch (DOMException $ e ) {
18
+ echo $ e ->getMessage (), "\n" ;
19
+ }
20
+ var_dump ($ child ->ownerDocument === $ doc );
21
+ ?>
22
+ --EXPECT--
23
+ <? xml version="1.0 "?>
24
+ <name><child/></name>
25
+ <newname/>
26
+ Wrong Document Error
27
+ bool(true)
You can’t perform that action at this time.
0 commit comments