Skip to content

Fixed bug #78577 - #4731

Closed
beberlei wants to merge 2 commits into
php:PHP-7.2from
beberlei:bug-78577-php7.2
Closed

beberlei wants to merge 2 commits into
php:PHP-7.2from
beberlei:bug-78577-php7.2

Conversation

@beberlei

@beberlei beberlei commented Sep 20, 2019 •

Copy link
Copy Markdown
Contributor

The nsparent should actually be the nodep already from the DOMElement#getAttributeNode() call.

Fixes https://bugs.php.net/bug.php?id=78577

@beberlei

Copy link
Copy Markdown
Contributor Author

Related to https://bugs.php.net/bug.php?id=70359

@nikic

nikic commented Sep 23, 2019

Copy link
Copy Markdown
Member

There's some similar code doing nsparent = node->_private in xpath.c.

@beberlei

Copy link
Copy Markdown
Contributor Author

@nikic You are right, multiple times actually. Going to try to get it to segfault as well using XPath in the test-case.

@beberlei

Copy link
Copy Markdown
Contributor Author

Triggering the copy pasted code in xpath.c does not lead to a segfault, so I think that @cmb69 assertion on the linked ticket is right, that the culprit is the invalid cast in dom_get_dom1_attribute.

@robrichards

Copy link
Copy Markdown

@beberlei I sent you a patch to try as the type case in that method was intentional. It was used incorrectly tho in the dom_element_get_attribute_node method

@krakjoe krakjoe added the Bug label Sep 30, 2019
@krakjoe

krakjoe commented Sep 30, 2019

Copy link
Copy Markdown
Member

Can we get a status update here please ?

@beberlei

beberlei commented Oct 4, 2019

Copy link
Copy Markdown
Contributor Author

So I wrote with @robrichards on this, and incorporated parts of a patch that he sent me. One problem is still that the previous code using _private doesn't work even though an explicit cast ((xmlNsPtr)attr)->_private; addresses the problem that the field is in different order compared to xmlNodePtr.

So i kept my part of the patch that uses nodep instead of attrp->_private for the parent node, because they are the same by the nature of the current DOM operation.

@beberlei

beberlei commented Oct 5, 2019

Copy link
Copy Markdown
Contributor Author

The fix is still not good, accessing $attr->parentNode will point to invalid memory when the parent node is removed from the DOM and garbage collected.

@github-actions

Copy link
Copy Markdown

There has not been any recent activity in this PR. It will automatically be closed in 7 days if no further action is taken.

@github-actions github-actions Bot added the Stale label Feb 15, 2022
@github-actions github-actions Bot closed this Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants