Bug 210353 - Null ptr Deref in RadioButtonGroups::updateCheckedState
Summary: Null ptr Deref in RadioButtonGroups::updateCheckedState
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Forms (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-04-10 13:27 PDT by Pinki Gyanchandani
Modified: 2020-04-10 16:16 PDT (History)
6 users (show)

See Also:


Attachments
Patch (3.62 KB, patch)
2020-04-10 13:37 PDT, Pinki Gyanchandani
no flags Details | Formatted Diff | Diff
Patch (3.58 KB, patch)
2020-04-10 14:26 PDT, Pinki Gyanchandani
no flags Details | Formatted Diff | Diff
Patch (3.59 KB, patch)
2020-04-10 15:45 PDT, Pinki Gyanchandani
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pinki Gyanchandani 2020-04-10 13:27:22 PDT
Crash is observed when default checked is called for HTML Input element and radioButtonGroup is NULL.
Comment 1 Pinki Gyanchandani 2020-04-10 13:29:25 PDT
rdar://problem/61290022
Comment 2 Pinki Gyanchandani 2020-04-10 13:37:51 PDT
Created attachment 396118 [details]
Patch
Comment 3 Wenson Hsieh 2020-04-10 13:44:32 PDT
Comment on attachment 396118 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=396118&action=review

> Source/WebCore/ChangeLog:8
> +        Crash happend when default checked setter was called an input element and RadioButtonGroup was NULL.

Nit - “This crash happened when the default…"

> Source/WebCore/ChangeLog:9
> +        Added a NULL pointer check before derefercing.

Nit - “dereferencing"

> LayoutTests/fast/forms/input-element-default-checked-setter-crash.html:1
> +<!DOCHTML>

Nit - <!DOCTYPE html>?
Comment 4 Wenson Hsieh 2020-04-10 13:52:40 PDT
Comment on attachment 396118 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=396118&action=review

> LayoutTests/fast/forms/input-element-default-checked-setter-crash.html:16
> +<meta id="meta1"> </meta>

I don’t think this meta tag is necessary to reproduce this crash.

Here’s a slightly simpler version of this test case:

<!DOCTYPE html>
<html>
<body>
<p>This test passes if there is no crash</p>
<div id="container">
    <iframe id="frame"></iframe>
    <input id="input" name=" " type="radio">
</div>
<script>
if (window.testRunner)
    testRunner.dumpAsText();
frame.onload = () => input.defaultChecked = true;
document.body.appendChild(container);
</script>
</body>
</html>
Comment 5 Chris Dumez 2020-04-10 13:54:40 PDT
Comment on attachment 396118 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=396118&action=review

> Source/WebCore/dom/RadioButtonGroups.cpp:231
> +    auto* group = m_nameToGroupMap.get(element.name().impl());

if (auto* group = m_nameToGroupMap.get(element.name().impl()))
    group->updateCheckedState(element)

would be more concise.
Comment 6 Pinki Gyanchandani 2020-04-10 14:26:42 PDT
Created attachment 396125 [details]
Patch
Comment 7 Pinki Gyanchandani 2020-04-10 14:27:59 PDT
Hi Chirs and Wensen,

Thanks for quick review comments. I have incorporated the comments.

Regards,
Pinki
Comment 8 Chris Dumez 2020-04-10 14:29:59 PDT
Comment on attachment 396125 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=396125&action=review

> Source/WebCore/ChangeLog:8
> +        This crash happend when the default checked setter was called for an input element and RadioButtonGroup was NULL.

typo: happend

> Source/WebCore/ChangeLog:9
> +        Added condition to deference the group only if it is valid.

typo: deference -> dereference
s/valid/non-null

> LayoutTests/fast/forms/input-element-default-checked-setter-crash.html:4
> +<p>This test passes if there is no crash</p>

nit: There should be a period at the end of your sentence.
Comment 9 Pinki Gyanchandani 2020-04-10 15:45:31 PDT
Created attachment 396131 [details]
Patch
Comment 10 EWS 2020-04-10 16:16:01 PDT
Committed r259911: <https://trac.webkit.org/changeset/259911>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 396131 [details].