Make getHostnamesWithCookies more robust
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Jun 2019 22:24:23 +0000 (22:24 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 28 Jun 2019 22:24:23 +0000 (22:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199334
<rdar://problem/51860593>

Patch by Alex Christensen <achristensen@webkit.org> on 2019-06-28
Reviewed by Brent Fulgham.

Crash logs suggest either httpCookies is returning a nil cookie or a cookie without a domain.
This should not happen, but if it does we shouldn't crash.

* platform/network/cocoa/NetworkStorageSessionCocoa.mm:
(WebCore::NetworkStorageSession::getHostnamesWithCookies):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@246942 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/network/cocoa/NetworkStorageSessionCocoa.mm

index 4232a32..22d2e8c 100644 (file)
@@ -1,3 +1,17 @@
+2019-06-28  Alex Christensen  <achristensen@webkit.org>
+
+        Make getHostnamesWithCookies more robust
+        https://bugs.webkit.org/show_bug.cgi?id=199334
+        <rdar://problem/51860593>
+
+        Reviewed by Brent Fulgham.
+
+        Crash logs suggest either httpCookies is returning a nil cookie or a cookie without a domain.
+        This should not happen, but if it does we shouldn't crash.
+
+        * platform/network/cocoa/NetworkStorageSessionCocoa.mm:
+        (WebCore::NetworkStorageSession::getHostnamesWithCookies):
+
 2019-06-28  chris fleizach  <cfleizach@apple.com>
 
         AX: Both convertToNSArray() functions in WebAccessibilityObjectWrapperBase.mm leak every NSMutableArray returned
index 557e977..84b73b8 100644 (file)
@@ -487,8 +487,12 @@ void NetworkStorageSession::getHostnamesWithCookies(HashSet<String>& hostnames)
 
     NSArray *cookies = httpCookies(cookieStorage().get());
     
-    for (NSHTTPCookie* cookie in cookies)
-        hostnames.add([cookie domain]);
+    for (NSHTTPCookie* cookie in cookies) {
+        if (NSString *domain = [cookie domain])
+            hostnames.add(domain);
+        else
+            ASSERT_NOT_REACHED();
+    }
     
     END_BLOCK_OBJC_EXCEPTIONS;
 }