-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix GH-16777: Calling the constructor again on a DOM object after it …
…is in a document causes UAF Closes GH-16824.
- Loading branch information
Showing
4 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--TEST-- | ||
GH-16777 (Calling the constructor again on a DOM object after it is in a document causes UAF) | ||
--EXTENSIONS-- | ||
dom | ||
--FILE-- | ||
<?php | ||
$text = new DOMText('my value'); | ||
$doc = new DOMDocument(); | ||
$doc->appendChild($text); | ||
$text->__construct('my new value'); | ||
$doc->appendChild($text); | ||
echo $doc->saveXML(); | ||
$dom2 = new DOMDocument(); | ||
try { | ||
$dom2->appendChild($text); | ||
} catch (DOMException $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
?> | ||
--EXPECT-- | ||
<?xml version="1.0"?> | ||
my value | ||
my new value | ||
Wrong Document Error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
--TEST-- | ||
GH-16777 (Calling the constructor again on a DOM object after it is in a document causes UAF) | ||
--EXTENSIONS-- | ||
dom | ||
--FILE-- | ||
<?php | ||
$el = new DOMElement('name'); | ||
$el->append($child = new DOMElement('child')); | ||
$doc = new DOMDocument(); | ||
$doc->appendChild($el); | ||
$el->__construct('newname'); | ||
$doc->appendChild($el); | ||
echo $doc->saveXML(); | ||
$dom2 = new DOMDocument(); | ||
try { | ||
$dom2->appendChild($el); | ||
} catch (DOMException $e) { | ||
echo $e->getMessage(), "\n"; | ||
} | ||
var_dump($child->ownerDocument === $doc); | ||
?> | ||
--EXPECT-- | ||
<?xml version="1.0"?> | ||
<name><child/></name> | ||
<newname/> | ||
Wrong Document Error | ||
bool(true) |