⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 259664 in webkit


Ignore:
Timestamp:
Apr 7, 2020, 1:03:20 PM (6 years ago)
Author:
Alan Coon
Message:

Apply patch. rdar://problem/61231957

Location:
branches/safari-609.2.1.2-branch/Source/WebKit
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-609.2.1.2-branch/Source/WebKit/ChangeLog

    r259663 r259664  
     12020-04-07  Russell Epstein  <repstein@apple.com>
     2
     3        Apply patch. rdar://problem/61231957
     4
     5    2020-04-07  David Kilzer  <ddkilzer@apple.com>
     6
     7            Cherry-pick r258334. rdar://problem/60396294
     8
     9        2020-03-12  David Kilzer  <ddkilzer@apple.com>
     10
     11            WebPasteboardProxy::SetPasteboardBufferForType should validate its `size` parameter
     12            <https://webkit.org/b/208902>
     13            <rdar://problem/60181117>
     14
     15            Reviewed by Chris Dumez.
     16
     17            * Platform/IPC/Connection.h:
     18            (MESSAGE_CHECK_BASE):
     19            - Define in terms of MESSAGE_CHECK_COMPLETION_BASE() with a
     20              no-op completion handler.
     21            (MESSAGE_CHECK_COMPLETION_BASE):
     22            - Rename from MESSAGE_CHECK_BASE() and add completion handler
     23              parameter.
     24
     25            * Platform/SharedMemory.h:
     26            (WebKit::SharedMemory::Handle::size const): Add.
     27
     28            * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
     29            (MESSAGE_CHECK):
     30            - Define macro to use in
     31              WebPasteboardProxy::setPasteboardBufferForType().
     32            - Undefine macro at end of source file due to unified sources.
     33            (WebKit::WebPasteboardProxy::setPasteboardBufferForType):
     34            - Add IPC::Connection& parameter after change to
     35              WebPasteboardProxy.messages.in.  Use with MESSAGE_CHECK().
     36            - Validate `size` parameter using MESSAGE_CHECK().  Because
     37              SharedMemory::Handle::size() returns a size_t value, we do not
     38              need to check `size <= std::numeric_limits<size_t>::max()`.
     39            - Add static_cast<size_t>() to size parameter to denote type
     40              change.
     41            * UIProcess/WebPasteboardProxy.h:
     42            (WebKit::WebPasteboardProxy::setPasteboardBufferForType):
     43            - Add IPC::Connection& parameter after change to
     44              WebPasteboardProxy.messages.in.
     45            * UIProcess/WebPasteboardProxy.messages.in:
     46            (SetPasteboardBufferForType):
     47            - Add 'WantsConnection' attribute to add IPC::Connection&
     48              parameter to WebPasteboardProxy::setPasteboardBufferForType().
     49
    1502020-04-07  Alan Coon  <alancoon@apple.com>
    251
  • branches/safari-609.2.1.2-branch/Source/WebKit/Platform/IPC/Connection.h

    r259663 r259664  
    7777};
    7878
    79 #define MESSAGE_CHECK_BASE(assertion, connection) do \
     79#define MESSAGE_CHECK_BASE(assertion, connection) MESSAGE_CHECK_COMPLETION_BASE(assertion, connection, (void)0)
     80
     81#define MESSAGE_CHECK_COMPLETION_BASE(assertion, connection, completion) do \
    8082    if (!(assertion)) { \
    8183        ASSERT(assertion); \
    8284        (connection)->markCurrentlyDispatchedMessageAsInvalid(); \
     85        { completion; } \
    8386        return; \
    8487    } \
  • branches/safari-609.2.1.2-branch/Source/WebKit/Platform/SharedMemory.h

    r251765 r259664  
    7373
    7474        bool isNull() const;
     75
     76#if OS(DARWIN) || OS(WINDOWS)
     77        size_t size() const { return m_size; }
     78#endif
    7579
    7680        void clear();
  • branches/safari-609.2.1.2-branch/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm

    r251421 r259664  
    2727#import "WebPasteboardProxy.h"
    2828
     29#import "Connection.h"
    2930#import "SandboxExtension.h"
    3031#import "WebProcessProxy.h"
     
    3536#import <WebCore/SharedBuffer.h>
    3637#import <wtf/URL.h>
     38
     39#define MESSAGE_CHECK(assertion, completion) MESSAGE_CHECK_COMPLETION_BASE(assertion, (&connection), completion)
    3740
    3841namespace WebKit {
     
    157160}
    158161
    159 void WebPasteboardProxy::setPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle& handle, uint64_t size, CompletionHandler<void(int64_t)>&& completionHandler)
     162void WebPasteboardProxy::setPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle& handle, uint64_t size, CompletionHandler<void(int64_t)>&& completionHandler)
    160163{
    161164    if (handle.isNull())
    162165        return completionHandler(PlatformPasteboard(pasteboardName).setBufferForType(0, pasteboardType));
     166
     167    // SharedMemory::Handle::size() is rounded up to the nearest page.
     168    MESSAGE_CHECK(size && size <= handle.size(), completionHandler(0));
     169
    163170    RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly);
    164     auto buffer = SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), size);
     171    auto buffer = SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), static_cast<size_t>(size));
    165172    completionHandler(PlatformPasteboard(pasteboardName).setBufferForType(buffer.ptr(), pasteboardType));
    166173}
     
    255262
    256263} // namespace WebKit
     264
     265#undef MESSAGE_CHECK
  • branches/safari-609.2.1.2-branch/Source/WebKit/UIProcess/WebPasteboardProxy.h

    r251421 r259664  
    9494    void setPasteboardColor(const String&, const WebCore::Color&, CompletionHandler<void(int64_t)>&&);
    9595    void setPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, const String&, CompletionHandler<void(int64_t)>&&);
    96     void setPasteboardBufferForType(const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle&, uint64_t size, CompletionHandler<void(int64_t)>&&);
     96    void setPasteboardBufferForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle&, uint64_t size, CompletionHandler<void(int64_t)>&&);
    9797#endif
    9898
  • branches/safari-609.2.1.2-branch/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in

    r252655 r259664  
    5757    SetPasteboardColor(String pasteboardName, WebCore::Color color) -> (int64_t changeCount) Synchronous
    5858    SetPasteboardStringForType(String pasteboardName, String pasteboardType, String string) -> (int64_t changeCount) Synchronous
    59     SetPasteboardBufferForType(String pasteboardName, String pasteboardType, WebKit::SharedMemory::Handle handle, uint64_t size) -> (int64_t changeCount) Synchronous
     59    SetPasteboardBufferForType(String pasteboardName, String pasteboardType, WebKit::SharedMemory::Handle handle, uint64_t size) -> (int64_t changeCount) Synchronous WantsConnection
    6060#endif
    6161
Note: See TracChangeset for help on using the changeset viewer.