Changeset 260316 in webkit


Ignore:
Timestamp:
Apr 18, 2020 9:35:05 AM (4 years ago)
Author:
ddkilzer@apple.com
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.
Location:
trunk/Source/WebKit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r260303 r260316  
     12020-04-18  David Kilzer  <ddkilzer@apple.com>
     2
     3        [IPC hardening] Use MESSAGE_CHECK in WebPasteboardProxy
     4        <https://webkit.org/b/210684>
     5        <rdar://problem/59906721>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
     10        - Add missing #undef of MESSAGE_CHECK_COMPLETION and
     11          MESSAGE_CHECK_WITH_RETURN_VALUE.
     12        (WebKit::WebPasteboardProxy::getPasteboardPathnamesForType):
     13        (WebKit::WebPasteboardProxy::getPasteboardStringForType):
     14        (WebKit::WebPasteboardProxy::getPasteboardStringsForType):
     15        (WebKit::WebPasteboardProxy::getPasteboardBufferForType):
     16        (WebKit::WebPasteboardProxy::setPasteboardStringForType):
     17        (WebKit::WebPasteboardProxy::setPasteboardBufferForType):
     18        (WebKit::WebPasteboardProxy::typesSafeForDOMToReadAndWrite):
     19        (WebKit::WebPasteboardProxy::readStringFromPasteboard):
     20        (WebKit::WebPasteboardProxy::readBufferFromPasteboard):
     21        - Replace existing code with MESSAGE_CHECK_COMPLETION macros.
     22
     23        * UIProcess/WebPasteboardProxy.cpp:
     24        (WebKit::WebPasteboardProxy::typesSafeForDOMToReadAndWrite):
     25        * UIProcess/WebPasteboardProxy.h:
     26        * UIProcess/WebPasteboardProxy.messages.in:
     27        - Add IPC::Connection to TypesSafeForDOMToReadAndWrite.
     28
    1292020-04-17  Kate Cheney  <katherine_cheney@apple.com>
    230
  • trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm

    r259346 r260316  
    128128    CompletionHandler<void(Vector<String>&& pathnames, SandboxExtension::HandleArray&& sandboxExtensions)>&& completionHandler)
    129129{
    130     ASSERT(!pasteboardType.isNull());
    131     if (pasteboardType.isNull())
    132         return completionHandler({ }, { });
     130    MESSAGE_CHECK_COMPLETION(!pasteboardType.isNull(), completionHandler({ }, { }));
    133131
    134132    // FIXME: This should consult canAccessPasteboardData() as well, and avoid responding with file paths if it returns false.
     
    154152void WebPasteboardProxy::getPasteboardStringForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(String&&)>&& completionHandler)
    155153{
     154    MESSAGE_CHECK_COMPLETION(!pasteboardType.isNull(), completionHandler({ }));
     155
    156156    if (!canAccessPasteboardData(connection, pasteboardName))
    157157        return completionHandler({ });
    158158
    159     ASSERT(!pasteboardType.isNull());
    160     if (pasteboardType.isNull())
     159    completionHandler(PlatformPasteboard(pasteboardName).stringForType(pasteboardType));
     160}
     161
     162void WebPasteboardProxy::getPasteboardStringsForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
     163{
     164    MESSAGE_CHECK_COMPLETION(!pasteboardType.isNull(), completionHandler({ }));
     165
     166    if (!canAccessPasteboardData(connection, pasteboardName))
    161167        return completionHandler({ });
    162168
    163     completionHandler(PlatformPasteboard(pasteboardName).stringForType(pasteboardType));
    164 }
    165 
    166 void WebPasteboardProxy::getPasteboardStringsForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
    167 {
    168     ASSERT(!pasteboardType.isNull());
    169     if (pasteboardType.isNull())
    170         return completionHandler({ });
    171 
    172     if (!canAccessPasteboardData(connection, pasteboardName))
    173         return completionHandler({ });
    174 
    175169    completionHandler(PlatformPasteboard(pasteboardName).allStringsForType(pasteboardType));
    176170}
     
    178172void WebPasteboardProxy::getPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, CompletionHandler<void(SharedMemory::Handle&&, uint64_t)>&& completionHandler)
    179173{
    180     ASSERT(!pasteboardType.isNull());
    181     if (pasteboardType.isNull())
    182         return completionHandler({ }, 0);
     174    MESSAGE_CHECK_COMPLETION(!pasteboardType.isNull(), completionHandler({ }, 0));
    183175
    184176    if (!canAccessPasteboardData(connection, pasteboardName))
     
    261253void WebPasteboardProxy::setPasteboardStringForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, const String& string, CompletionHandler<void(int64_t)>&& completionHandler)
    262254{
    263     ASSERT(!pasteboardType.isNull());
    264     if (pasteboardType.isNull())
    265         return completionHandler(0);
     255    MESSAGE_CHECK_COMPLETION(!pasteboardType.isNull(), completionHandler(0));
    266256
    267257    auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount();
     
    288278void WebPasteboardProxy::setPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle& handle, uint64_t size, CompletionHandler<void(int64_t)>&& completionHandler)
    289279{
    290     ASSERT(!pasteboardType.isNull());
    291     if (pasteboardType.isNull())
    292         return completionHandler(0);
     280    MESSAGE_CHECK_COMPLETION(!pasteboardType.isNull(), completionHandler(0));
    293281
    294282    auto previousChangeCount = PlatformPasteboard(pasteboardName).changeCount();
     
    316304}
    317305
    318 void WebPasteboardProxy::typesSafeForDOMToReadAndWrite(const String& pasteboardName, const String& origin, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
    319 {
    320     ASSERT(!origin.isNull());
    321     if (origin.isNull())
    322         return completionHandler({ });
     306void WebPasteboardProxy::typesSafeForDOMToReadAndWrite(IPC::Connection& connection, const String& pasteboardName, const String& origin, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
     307{
     308    MESSAGE_CHECK_COMPLETION(!origin.isNull(), completionHandler({ }));
    323309
    324310    completionHandler(PlatformPasteboard(pasteboardName).typesSafeForDOMToReadAndWrite(origin));
     
    350336void WebPasteboardProxy::readStringFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(String&&)>&& completionHandler)
    351337{
    352     ASSERT(!pasteboardType.isNull());
    353     if (pasteboardType.isNull())
    354         return completionHandler({ });
     338    MESSAGE_CHECK_COMPLETION(!pasteboardType.isNull(), completionHandler({ }));
    355339
    356340    if (!canAccessPasteboardData(connection, pasteboardName))
     
    372356void WebPasteboardProxy::readBufferFromPasteboard(IPC::Connection& connection, size_t index, const String& pasteboardType, const String& pasteboardName, CompletionHandler<void(SharedMemory::Handle&&, uint64_t size)>&& completionHandler)
    373357{
    374     ASSERT(!pasteboardType.isNull());
    375     if (pasteboardType.isNull())
    376         return completionHandler({ }, 0);
     358    MESSAGE_CHECK_COMPLETION(!pasteboardType.isNull(), completionHandler({ }, 0));
    377359
    378360    if (!canAccessPasteboardData(connection, pasteboardName))
     
    438420} // namespace WebKit
    439421
     422#undef MESSAGE_CHECK_COMPLETION
     423#undef MESSAGE_CHECK_WITH_RETURN_VALUE
    440424#undef MESSAGE_CHECK
  • trunk/Source/WebKit/UIProcess/WebPasteboardProxy.cpp

    r259151 r260316  
    8080#if !PLATFORM(COCOA)
    8181
    82 void WebPasteboardProxy::typesSafeForDOMToReadAndWrite(const String&, const String&, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
     82void WebPasteboardProxy::typesSafeForDOMToReadAndWrite(IPC::Connection&, const String&, const String&, CompletionHandler<void(Vector<String>&&)>&& completionHandler)
    8383{
    8484    completionHandler({ });
  • trunk/Source/WebKit/UIProcess/WebPasteboardProxy.h

    r259151 r260316  
    112112
    113113    void writeCustomData(IPC::Connection&, const Vector<WebCore::PasteboardCustomData>&, const String& pasteboardName, CompletionHandler<void(int64_t)>&&);
    114     void typesSafeForDOMToReadAndWrite(const String& pasteboardName, const String& origin, CompletionHandler<void(Vector<String>&&)>&&);
     114    void typesSafeForDOMToReadAndWrite(IPC::Connection&, const String& pasteboardName, const String& origin, CompletionHandler<void(Vector<String>&&)>&&);
    115115    void containsStringSafeForDOMToReadForType(const String&, const String& pasteboardName, CompletionHandler<void(bool)>&&);
    116116    void containsURLStringSuitableForLoading(const String& pasteboardName, CompletionHandler<void(bool)>&&);
  • trunk/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in

    r259151 r260316  
    3131
    3232    WriteCustomData(Vector<WebCore::PasteboardCustomData> data, String pasteboardName) -> (int64_t changeCount) Synchronous WantsConnection
    33     TypesSafeForDOMToReadAndWrite(String pasteboardName, String origin) -> (Vector<String> types) Synchronous
     33    TypesSafeForDOMToReadAndWrite(String pasteboardName, String origin) -> (Vector<String> types) Synchronous WantsConnection
    3434    AllPasteboardItemInfo(String pasteboardName, int64_t changeCount) -> (Optional<Vector<WebCore::PasteboardItemInfo>> allInfo) Synchronous
    3535    InformationForItemAtIndex(uint64_t index, String pasteboardName, int64_t changeCount) -> (Optional<WebCore::PasteboardItemInfo> info) Synchronous
Note: See TracChangeset for help on using the changeset viewer.