Title: [254588] branches/safari-609-branch/Source/WebKit
Revision
254588
Author
alanc...@apple.com
Date
2020-01-15 11:14:42 -0800 (Wed, 15 Jan 2020)

Log Message

Cherry-pick r254092. rdar://problem/58552872

    NetworkSessionCocoa::isolatedSession should not use iterator after mutating m_isolatedSessions
    https://bugs.webkit.org/show_bug.cgi?id=205824
    <rdar://problem/55107625>

    Patch by Alex Christensen <achristen...@webkit.org> on 2020-01-06
    Reviewed by Chris Dumez.

    Classic iterator use after mutating iterated container was causing crashes by returning a null SessionWrapper&
    This was introduced in r252185 or r248640.

    * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
    (WebKit::NetworkSessionCocoa::isolatedSession):

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

Modified Paths

Diff

Modified: branches/safari-609-branch/Source/WebKit/ChangeLog (254587 => 254588)


--- branches/safari-609-branch/Source/WebKit/ChangeLog	2020-01-15 19:14:39 UTC (rev 254587)
+++ branches/safari-609-branch/Source/WebKit/ChangeLog	2020-01-15 19:14:42 UTC (rev 254588)
@@ -1,5 +1,38 @@
 2020-01-14  Alan Coon  <alanc...@apple.com>
 
+        Cherry-pick r254092. rdar://problem/58552872
+
+    NetworkSessionCocoa::isolatedSession should not use iterator after mutating m_isolatedSessions
+    https://bugs.webkit.org/show_bug.cgi?id=205824
+    <rdar://problem/55107625>
+    
+    Patch by Alex Christensen <achristen...@webkit.org> on 2020-01-06
+    Reviewed by Chris Dumez.
+    
+    Classic iterator use after mutating iterated container was causing crashes by returning a null SessionWrapper&
+    This was introduced in r252185 or r248640.
+    
+    * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+    (WebKit::NetworkSessionCocoa::isolatedSession):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254092 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-01-06  Alex Christensen  <achristen...@webkit.org>
+
+            NetworkSessionCocoa::isolatedSession should not use iterator after mutating m_isolatedSessions
+            https://bugs.webkit.org/show_bug.cgi?id=205824
+            <rdar://problem/55107625>
+
+            Reviewed by Chris Dumez.
+
+            Classic iterator use after mutating iterated container was causing crashes by returning a null SessionWrapper&
+            This was introduced in r252185 or r248640.
+
+            * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+            (WebKit::NetworkSessionCocoa::isolatedSession):
+
+2020-01-14  Alan Coon  <alanc...@apple.com>
+
         Cherry-pick r254078. rdar://problem/58549073
 
     Reformat WebPage logging

Modified: branches/safari-609-branch/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (254587 => 254588)


--- branches/safari-609-branch/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2020-01-15 19:14:39 UTC (rev 254587)
+++ branches/safari-609-branch/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2020-01-15 19:14:42 UTC (rev 254588)
@@ -1194,6 +1194,21 @@
 
     entry->lastUsed = WallTime::now();
 
+    auto& sessionWrapper = [&] (auto storedCredentialsPolicy) -> SessionWrapper& {
+        switch (storedCredentialsPolicy) {
+        case WebCore::StoredCredentialsPolicy::Use:
+            LOG(NetworkSession, "Using isolated NSURLSession with credential storage.");
+            return entry->sessionWithCredentialStorage;
+        case WebCore::StoredCredentialsPolicy::DoNotUse:
+            LOG(NetworkSession, "Using isolated NSURLSession without credential storage.");
+            return entry->sessionWithoutCredentialStorage;
+        case WebCore::StoredCredentialsPolicy::EphemeralStateless:
+            if (!m_ephemeralStatelessSession.session)
+                initializeEphemeralStatelessSession();
+            return m_ephemeralStatelessSession;
+        }
+    } (storedCredentialsPolicy);
+    
     if (m_isolatedSessions.size() > maxNumberOfIsolatedSessions) {
         WebCore::RegistrableDomain keyToRemove;
         auto oldestTimestamp = WallTime::now();
@@ -1210,18 +1225,7 @@
 
     RELEASE_ASSERT(m_isolatedSessions.size() <= maxNumberOfIsolatedSessions);
 
-    switch (storedCredentialsPolicy) {
-    case WebCore::StoredCredentialsPolicy::Use:
-        LOG(NetworkSession, "Using isolated NSURLSession with credential storage.");
-        return entry->sessionWithCredentialStorage;
-    case WebCore::StoredCredentialsPolicy::DoNotUse:
-        LOG(NetworkSession, "Using isolated NSURLSession without credential storage.");
-        return entry->sessionWithoutCredentialStorage;
-    case WebCore::StoredCredentialsPolicy::EphemeralStateless:
-        if (!m_ephemeralStatelessSession.session)
-            initializeEphemeralStatelessSession();
-        return m_ephemeralStatelessSession;
-    }
+    return sessionWrapper;
 }
 
 bool NetworkSessionCocoa::hasIsolatedSession(const WebCore::RegistrableDomain domain) const
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to