| Summary: | Null dereference in CompositeEditCommand::splitTreeToNode() due to not checking for top of DOM tree | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Julian Gonzalez <julian_a_gonzalez> | ||||||||||
| Component: | HTML Editing | Assignee: | Nobody <webkit-unassigned> | ||||||||||
| Status: | RESOLVED FIXED | ||||||||||||
| Severity: | Normal | CC: | achristensen, bfulgham, ews-feeder, ews-watchlist, mifenton, product-security, rniwa, webkit-bug-importer, wenson_hsieh | ||||||||||
| Priority: | P2 | Keywords: | InRadar | ||||||||||
| Version: | WebKit Nightly Build | ||||||||||||
| Hardware: | Unspecified | ||||||||||||
| OS: | Unspecified | ||||||||||||
| Attachments: |
|
||||||||||||
|
Description
Julian Gonzalez
2020-10-26 17:25:22 PDT
<rdar://problem/66864853> Null Ptr Deref @ WebCore::CompositeEditCommand::splitTreeToNode -- DOS WebKitTestRunner WK2 Created attachment 412366 [details]
Patch
Comment on attachment 412366 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=412366&action=review > Source/WebCore/editing/CompositeEditCommand.cpp:1716 > + for (node = &start; node && node->parentNode() && node->parentNode() != adjustedEnd; node = node->parentNode()) { > if (!is<Element>(*node->parentNode())) Can we avoid calling parentNode() four times here? Fixed that in the new patch, which also addresses the failure of the new test on the debug build. Created attachment 412688 [details]
Patch
Comment on attachment 412688 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=412688&action=review > Source/WebCore/editing/InsertListCommand.cpp:324 > + Node* lcnParentNode = listChildNode->parentNode(); Please don't use raw pointer. Use makeRefPtr to store it in RefPtr. Also please don't abbreviations like lcn. Comment on attachment 412688 [details]
Patch
I think these test failures are legitimate.
(In reply to Ryosuke Niwa from comment #7) > Comment on attachment 412688 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=412688&action=review > > > Source/WebCore/editing/InsertListCommand.cpp:324 > > + Node* lcnParentNode = listChildNode->parentNode(); > > Please don't use raw pointer. Use makeRefPtr to store it in RefPtr. > Also please don't abbreviations like lcn. Fixed in new patch. (In reply to Ryosuke Niwa from comment #8) > Comment on attachment 412688 [details] > Patch > > I think these test failures are legitimate. Agreed, I can now reproduce them locally. I have a new patch that I'm preparing that should address them. Created attachment 413379 [details]
Patch
Comment on attachment 413379 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=413379&action=review > LayoutTests/editing/inserting/insert-list-in-iframe-in-list-expected.txt:3 > +This tests that we do not crah while inserting either list. crash Comment on attachment 413379 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=413379&action=review > Source/WebCore/editing/InsertListCommand.cpp:324 > + RefPtr<Node> listChildNodeParentNode = makeRefPtr(listChildNode->parentNode()); Use auto. > Source/WebCore/editing/InsertListCommand.cpp:325 > + if (listChildNodeParentNode && listChildNodeParentNode != listNode) Declare the variable in if as in: if (auto listChildNodeParentNode = ~; listChildNodeParentNode != listNode) Comment on attachment 413379 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=413379&action=review >> Source/WebCore/editing/InsertListCommand.cpp:325 >> + if (listChildNodeParentNode && listChildNodeParentNode != listNode) > > Declare the variable in if as in: > if (auto listChildNodeParentNode = ~; listChildNodeParentNode != listNode) if (auto listChildNodeParentNode = makeRefPtr(listChildNode->parentNode()); listChildNodeParentNode && listChildNodeParentNode != listNode) Hooray C++17! There is no security implication here. (In reply to Alex Christensen from comment #12) > Comment on attachment 413379 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=413379&action=review > > > LayoutTests/editing/inserting/insert-list-in-iframe-in-list-expected.txt:3 > > +This tests that we do not crah while inserting either list. > > crash Thanks :P (In reply to Alex Christensen from comment #14) > Comment on attachment 413379 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=413379&action=review > > >> Source/WebCore/editing/InsertListCommand.cpp:325 > >> + if (listChildNodeParentNode && listChildNodeParentNode != listNode) > > > > Declare the variable in if as in: > > if (auto listChildNodeParentNode = ~; listChildNodeParentNode != listNode) > > if (auto listChildNodeParentNode = makeRefPtr(listChildNode->parentNode()); > listChildNodeParentNode && listChildNodeParentNode != listNode) > > Hooray C++17! Upgrading my mental C++ model is a slow process :) Thank you both. Created attachment 413617 [details]
Patch
Committed r269609: <https://trac.webkit.org/changeset/269609> All reviewed patches have been landed. Closing bug and clearing flags on attachment 413617 [details]. |