Title: [260316] trunk/Source/WebKit
Revision
260316
Author
ddkil...@apple.com
Date
2020-04-18 09:35:05 -0700 (Sat, 18 Apr 2020)

Log Message

[IPC hardening] Use MESSAGE_CHECK in WebPasteboardProxy
<https://webkit.org/b/210684>
<rdar://problem/59906721>

Reviewed by Wenson Hsieh.

* UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
- Add missing #undef of MESSAGE_CHECK_COMPLETION and
  MESSAGE_CHECK_WITH_RETURN_VALUE.
(WebKit::WebPasteboardProxy::getPasteboardPathnamesForType):
(WebKit::WebPasteboardProxy::getPasteboardStringForType):
(WebKit::WebPasteboardProxy::getPasteboardStringsForType):
(WebKit::WebPasteboardProxy::getPasteboardBufferForType):
(WebKit::WebPasteboardProxy::setPasteboardStringForType):
(WebKit::WebPasteboardProxy::setPasteboardBufferForType):
(WebKit::WebPasteboardProxy::typesSafeForDOMToReadAndWrite):
(WebKit::WebPasteboardProxy::readStringFromPasteboard):
(WebKit::WebPasteboardProxy::readBufferFromPasteboard):
- Replace existing code with MESSAGE_CHECK_COMPLETION macros.

* UIProcess/WebPasteboardProxy.cpp:
(WebKit::WebPasteboardProxy::typesSafeForDOMToReadAndWrite):
* UIProcess/WebPasteboardProxy.h:
* UIProcess/WebPasteboardProxy.messages.in:
- Add IPC::Connection to TypesSafeForDOMToReadAndWrite.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (260315 => 260316)


--- trunk/Source/WebKit/ChangeLog	2020-04-18 16:33:03 UTC (rev 260315)
+++ trunk/Source/WebKit/ChangeLog	2020-04-18 16:35:05 UTC (rev 260316)
@@ -1,3 +1,31 @@
+2020-04-18  David Kilzer  <ddkil...@apple.com>
+
+        [IPC hardening] Use MESSAGE_CHECK in WebPasteboardProxy
+        <https://webkit.org/b/210684>
+        <rdar://problem/59906721>
+
+        Reviewed by Wenson Hsieh.
+
+        * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
+        - Add missing #undef of MESSAGE_CHECK_COMPLETION and
+          MESSAGE_CHECK_WITH_RETURN_VALUE.
+        (WebKit::WebPasteboardProxy::getPasteboardPathnamesForType):
+        (WebKit::WebPasteboardProxy::getPasteboardStringForType):
+        (WebKit::WebPasteboardProxy::getPasteboardStringsForType):
+        (WebKit::WebPasteboardProxy::getPasteboardBufferForType):
+        (WebKit::WebPasteboardProxy::setPasteboardStringForType):
+        (WebKit::WebPasteboardProxy::setPasteboardBufferForType):
+        (WebKit::WebPasteboardProxy::typesSafeForDOMToReadAndWrite):
+        (WebKit::WebPasteboardProxy::readStringFromPasteboard):
+        (WebKit::WebPasteboardProxy::readBufferFromPasteboard):
+        - Replace existing code with MESSAGE_CHECK_COMPLETION macros.
+
+        * UIProcess/WebPasteboardProxy.cpp:
+        (WebKit::WebPasteboardProxy::typesSafeForDOMToReadAndWrite):
+        * UIProcess/WebPasteboardProxy.h:
+        * UIProcess/WebPasteboardProxy.messages.in:
+        - Add IPC::Connection to TypesSafeForDOMToReadAndWrite.
+
 2020-04-17  Kate Cheney  <katherine_che...@apple.com>
 
         Enable service workers for app-bound domains

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm (260315 => 260316)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm	2020-04-18 16:33:03 UTC (rev 260315)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm	2020-04-18 16:35:05 UTC (rev 260316)
@@ -127,9 +127,7 @@
 void WebPasteboardProxy::getPasteboardPathnamesForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType,
     CompletionHandler<void(Vector<String>&& pathnames, SandboxExtension::HandleArray&& sandboxExtensions)>&& completionHandler)
 {
-    ASSERT(!pasteboardType.isNull());
-    if (pasteboardType.isNull())
-        return completionHandler({ }, { });
+    MESSAGE_CHECK_COMPLETION(!pasteboardType.isNull(), completionHandler({ }, { }));
 
     // FIXME: This should consult canAccessPasteboardData() as well, and avoid responding with file paths if it returns false.
     Vector<String> pathnames;
@@ -153,21 +151,17 @@
 
 void WebPasteboardProxy::getPasteboardStringForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(String&&)>&& completionHandler)
 {
+    MESSAGE_CHECK_COMPLETION(!pasteboardType.isNull(), completionHandler({ }));
+
     if (!canAccessPasteboardData(connection, pasteboardName))
         return completionHandler({ });
 
-    ASSERT(!pasteboardType.isNull());
-    if (pasteboardType.isNull())
-        return completionHandler({ });
-
     completionHandler(PlatformPasteboard(pasteboardName).stringForType(pasteboardType));
 }
 
 void WebPasteboardProxy::getPasteboardStringsForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
 {
-    ASSERT(!pasteboardType.isNull());
-    if (pasteboardType.isNull())
-        return completionHandler({ });
+    MESSAGE_CHECK_COMPLETION(!pasteboardType.isNull(), completionHandler({ }));
 
     if (!canAccessPasteboardData(connection, pasteboardName))
         return completionHandler({ });
@@ -177,9 +171,7 @@
 
 void WebPasteboardProxy::getPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(SharedMemory::Handle&&, uint64_t)>&& completionHandler)
 {
-    ASSERT(!pasteboardType.isNull());
-    if (pasteboardType.isNull())
-        return completionHandler({ }, 0);
+    MESSAGE_CHECK_COMPLETION(!pasteboardType.isNull(), completionHandler({ }, 0));
 
     if (!canAccessPasteboardData(connection, pasteboardName))
         return completionHandler({ }, 0);
@@ -260,9 +252,7 @@
 
 void WebPasteboardProxy::setPasteboardStringForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, const String& string, CompletionHandler<void(int64_t)>&& completionHandler)
 {
-    ASSERT(!pasteboardType.isNull());
-    if (pasteboardType.isNull())
-        return completionHandler(0);
+    MESSAGE_CHECK_COMPLETION(!pasteboardType.isNull(), completionHandler(0));
 
     auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount();
     auto newChangeCount = PlatformPasteboard(pasteboardName).setStringForType(string, pasteboardType);
@@ -287,9 +277,7 @@
 
 void WebPasteboardProxy::setPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle& handle, uint64_t size, CompletionHandler<void(int64_t)>&& completionHandler)
 {
-    ASSERT(!pasteboardType.isNull());
-    if (pasteboardType.isNull())
-        return completionHandler(0);
+    MESSAGE_CHECK_COMPLETION(!pasteboardType.isNull(), completionHandler(0));
 
     auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount();
     if (handle.isNull()) {
@@ -315,11 +303,9 @@
     completionHandler(PlatformPasteboard(pasteboardName).numberOfFiles());
 }
 
-void WebPasteboardProxy::typesSafeForDOMToReadAndWrite(const String& pasteboardName, const String& origin, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
+void WebPasteboardProxy::typesSafeForDOMToReadAndWrite(IPC::Connection& connection, const String& pasteboardName, const String& origin, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
 {
-    ASSERT(!origin.isNull());
-    if (origin.isNull())
-        return completionHandler({ });
+    MESSAGE_CHECK_COMPLETION(!origin.isNull(), completionHandler({ }));
 
     completionHandler(PlatformPasteboard(pasteboardName).typesSafeForDOMToReadAndWrite(origin));
 }
@@ -349,9 +335,7 @@
 
 void WebPasteboardProxy::readStringFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(String&&)>&& completionHandler)
 {
-    ASSERT(!pasteboardType.isNull());
-    if (pasteboardType.isNull())
-        return completionHandler({ });
+    MESSAGE_CHECK_COMPLETION(!pasteboardType.isNull(), completionHandler({ }));
 
     if (!canAccessPasteboardData(connection, pasteboardName))
         return completionHandler({ });
@@ -371,9 +355,7 @@
 
 void WebPasteboardProxy::readBufferFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(SharedMemory::Handle&&, uint64_t size)>&& completionHandler)
 {
-    ASSERT(!pasteboardType.isNull());
-    if (pasteboardType.isNull())
-        return completionHandler({ }, 0);
+    MESSAGE_CHECK_COMPLETION(!pasteboardType.isNull(), completionHandler({ }, 0));
 
     if (!canAccessPasteboardData(connection, pasteboardName))
         return completionHandler({ }, 0);
@@ -437,4 +419,6 @@
 
 } // namespace WebKit
 
+#undef MESSAGE_CHECK_COMPLETION
+#undef MESSAGE_CHECK_WITH_RETURN_VALUE
 #undef MESSAGE_CHECK

Modified: trunk/Source/WebKit/UIProcess/WebPasteboardProxy.cpp (260315 => 260316)


--- trunk/Source/WebKit/UIProcess/WebPasteboardProxy.cpp	2020-04-18 16:33:03 UTC (rev 260315)
+++ trunk/Source/WebKit/UIProcess/WebPasteboardProxy.cpp	2020-04-18 16:35:05 UTC (rev 260316)
@@ -79,7 +79,7 @@
 
 #if !PLATFORM(COCOA)
 
-void WebPasteboardProxy::typesSafeForDOMToReadAndWrite(const String&, const String&, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
+void WebPasteboardProxy::typesSafeForDOMToReadAndWrite(IPC::Connection&, const String&, const String&, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
 {
     completionHandler({ });
 }

Modified: trunk/Source/WebKit/UIProcess/WebPasteboardProxy.h (260315 => 260316)


--- trunk/Source/WebKit/UIProcess/WebPasteboardProxy.h	2020-04-18 16:33:03 UTC (rev 260315)
+++ trunk/Source/WebKit/UIProcess/WebPasteboardProxy.h	2020-04-18 16:35:05 UTC (rev 260316)
@@ -111,7 +111,7 @@
     void allPasteboardItemInfo(const String& pasteboardName, int64_t changeCount, CompletionHandler<void(Optional<Vector<WebCore::PasteboardItemInfo>>&&)>&&);
 
     void writeCustomData(IPC::Connection&, const Vector<WebCore::PasteboardCustomData>&, const String& pasteboardName, CompletionHandler<void(int64_t)>&&);
-    void typesSafeForDOMToReadAndWrite(const String& pasteboardName, const String& origin, CompletionHandler<void(Vector<String>&&)>&&);
+    void typesSafeForDOMToReadAndWrite(IPC::Connection&, const String& pasteboardName, const String& origin, CompletionHandler<void(Vector<String>&&)>&&);
     void containsStringSafeForDOMToReadForType(const String&, const String& pasteboardName, CompletionHandler<void(bool)>&&);
     void containsURLStringSuitableForLoading(const String& pasteboardName, CompletionHandler<void(bool)>&&);
     void urlStringSuitableForLoading(IPC::Connection&, const String& pasteboardName, CompletionHandler<void(String&& url, String&& title)>&&);

Modified: trunk/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in (260315 => 260316)


--- trunk/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in	2020-04-18 16:33:03 UTC (rev 260315)
+++ trunk/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in	2020-04-18 16:35:05 UTC (rev 260316)
@@ -30,7 +30,7 @@
 #endif
 
     WriteCustomData(Vector<WebCore::PasteboardCustomData> data, String pasteboardName) -> (int64_t changeCount) Synchronous WantsConnection
-    TypesSafeForDOMToReadAndWrite(String pasteboardName, String origin) -> (Vector<String> types) Synchronous
+    TypesSafeForDOMToReadAndWrite(String pasteboardName, String origin) -> (Vector<String> types) Synchronous WantsConnection
     AllPasteboardItemInfo(String pasteboardName, int64_t changeCount) -> (Optional<Vector<WebCore::PasteboardItemInfo>> allInfo) Synchronous
     InformationForItemAtIndex(uint64_t index, String pasteboardName, int64_t changeCount) -> (Optional<WebCore::PasteboardItemInfo> info) Synchronous
     GetPasteboardItemsCount(String pasteboardName) -> (uint64_t itemsCount) Synchronous
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to