Add a graceful exit for AuthenticationManager::initializeConnection
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Jun 2018 18:54:49 +0000 (18:54 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 Jun 2018 18:54:49 +0000 (18:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186632
<rdar://problem/41041033>

Reviewed by Brent Fulgham.

Source/WebKit:

Add a graceful exit for AuthenticationManager::initializeConnection when the provided IPC connection
is null or the underlying xpc connection is null.

* Shared/Authentication/cocoa/AuthenticationManagerCocoa.mm:
(WebKit::AuthenticationManager::initializeConnection):

Source/WTF:

* wtf/spi/darwin/XPCSPI.h:

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

Source/WTF/ChangeLog
Source/WTF/wtf/spi/darwin/XPCSPI.h
Source/WebKit/ChangeLog
Source/WebKit/Shared/Authentication/cocoa/AuthenticationManagerCocoa.mm

index ce56921..a9c791b 100644 (file)
@@ -1,3 +1,13 @@
+2018-06-18  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Add a graceful exit for AuthenticationManager::initializeConnection
+        https://bugs.webkit.org/show_bug.cgi?id=186632
+        <rdar://problem/41041033>
+
+        Reviewed by Brent Fulgham.
+
+        * wtf/spi/darwin/XPCSPI.h:
+
 2018-06-18  Carlos Alberto Lopez Perez  <clopez@igalia.com>
 
         [WTF] Remove workarounds needed to support libstdc++-4
index 8c6ee3c..1a33e2e 100644 (file)
@@ -72,6 +72,7 @@ typedef void (*xpc_connection_handler_t)(xpc_connection_t connection);
 #define XPC_ERROR_TERMINATION_IMMINENT XPC_GLOBAL_OBJECT(_xpc_error_termination_imminent)
 #define XPC_TYPE_ARRAY (&_xpc_type_array)
 #define XPC_TYPE_BOOL (&_xpc_type_bool)
+#define XPC_TYPE_CONNECTION (&_xpc_type_connection)
 #define XPC_TYPE_DICTIONARY (&_xpc_type_dictionary)
 #define XPC_TYPE_ERROR (&_xpc_type_error)
 #define XPC_TYPE_STRING (&_xpc_type_string)
index 624928f..34429f3 100644 (file)
@@ -1,3 +1,17 @@
+2018-06-18  Jiewen Tan  <jiewen_tan@apple.com>
+
+        Add a graceful exit for AuthenticationManager::initializeConnection
+        https://bugs.webkit.org/show_bug.cgi?id=186632
+        <rdar://problem/41041033>
+
+        Reviewed by Brent Fulgham.
+
+        Add a graceful exit for AuthenticationManager::initializeConnection when the provided IPC connection
+        is null or the underlying xpc connection is null.
+
+        * Shared/Authentication/cocoa/AuthenticationManagerCocoa.mm:
+        (WebKit::AuthenticationManager::initializeConnection):
+
 2018-06-18  Youenn Fablet  <youenn@apple.com>
 
         Validate Cross-Origin-Resource-Policy for resources cached in the MemoryCache
index 080c61e..b86ae8a 100644 (file)
@@ -40,6 +40,11 @@ void AuthenticationManager::initializeConnection(IPC::Connection* connection)
 {
     ASSERT(isMainThread());
 
+    if (!connection || xpc_get_type(connection->xpcConnection()) != XPC_TYPE_CONNECTION) {
+        ASSERT_NOT_REACHED();
+        return;
+    }
+
     auto weakThis = makeWeakPtr(*this);
     // The following xpc event handler overwrites the boostrap event handler and is only used
     // to capture client certificate credential.