Bug 218626 - Fix crashes around NetworkStorageSession::registerCookieChangeListenersIfNecessary
Summary: Fix crashes around NetworkStorageSession::registerCookieChangeListenersIfNece...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-11-05 11:02 PST by Alex Christensen
Modified: 2020-11-06 08:02 PST (History)
2 users (show)

See Also:


Attachments
Patch (5.27 KB, patch)
2020-11-05 11:05 PST, Alex Christensen
no flags Details | Formatted Diff | Diff
patch (4.23 KB, patch)
2020-11-05 17:41 PST, Alex Christensen
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2020-11-05 11:02:19 PST
Fix crashes around NetworkStorageSession::registerCookieChangeListenersIfNecessary
Comment 1 Alex Christensen 2020-11-05 11:05:01 PST
Created attachment 413326 [details]
Patch
Comment 2 Chris Dumez 2020-11-05 11:29:42 PST
Comment on attachment 413326 [details]
Patch

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

> Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm:671
> +    [nsCookieStorage() _setCookiesChangedHandler:^(NSArray<NSHTTPCookie *> *, NSString *) { } onQueue:dispatch_get_main_queue()];

Why these changes?

> Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm:674
> +    [nsCookieStorage() _setSubscribedDomainsForCookieChanges:[NSSet set]];

ditto.
Comment 3 Alex Christensen 2020-11-05 14:41:24 PST
(In reply to Chris Dumez from comment #2)
> Comment on attachment 413326 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=413326&action=review
> 
> > Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm:671
> > +    [nsCookieStorage() _setCookiesChangedHandler:^(NSArray<NSHTTPCookie *> *, NSString *) { } onQueue:dispatch_get_main_queue()];
> 
> Why these changes?
CFNetwork calls the block without checking if it is nil.  This will cause it to call a block that does nothing instead of dereferencing null and crashing.
> 
> > Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm:674
> > +    [nsCookieStorage() _setSubscribedDomainsForCookieChanges:[NSSet set]];
> 
> ditto.
This one is probably not necessary, but I thought it wouldn't hurt to go along with the non-null theme of the other changes.
Comment 4 Chris Dumez 2020-11-05 16:35:46 PST
Jiten tells me this is very related to rdar://64024242. Do we still need a WebKit change or is that fix at rdar://64024242 sufficient?
Comment 5 Alex Christensen 2020-11-05 17:38:05 PST
Comment on attachment 413326 [details]
Patch

He definitely fixed at least part of the problem, but the weakThis check might still be necessary.  There's no reason to not take this change to be as safe as possible.
Comment 6 Alex Christensen 2020-11-05 17:41:51 PST
Created attachment 413380 [details]
patch
Comment 7 EWS 2020-11-06 08:01:36 PST
Committed r269512: <https://trac.webkit.org/changeset/269512>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 413380 [details].
Comment 8 Radar WebKit Bug Importer 2020-11-06 08:02:36 PST
<rdar://problem/71119360>