Changeset 258334 in webkit
- Timestamp:
- Mar 12, 2020 9:28:22 AM (4 years ago)
- Location:
- trunk/Source/WebKit
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r258329 r258334 1 2020-03-12 David Kilzer <ddkilzer@apple.com> 2 3 WebPasteboardProxy::SetPasteboardBufferForType should validate its `size` parameter 4 <https://webkit.org/b/208902> 5 <rdar://problem/60181117> 6 7 Reviewed by Chris Dumez. 8 9 * Platform/IPC/Connection.h: 10 (MESSAGE_CHECK_BASE): 11 - Define in terms of MESSAGE_CHECK_COMPLETION_BASE() with a 12 no-op completion handler. 13 (MESSAGE_CHECK_COMPLETION_BASE): 14 - Rename from MESSAGE_CHECK_BASE() and add completion handler 15 parameter. 16 17 * Platform/SharedMemory.h: 18 (WebKit::SharedMemory::Handle::size const): Add. 19 20 * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm: 21 (MESSAGE_CHECK): 22 - Define macro to use in 23 WebPasteboardProxy::setPasteboardBufferForType(). 24 - Undefine macro at end of source file due to unified sources. 25 (WebKit::WebPasteboardProxy::setPasteboardBufferForType): 26 - Add IPC::Connection& parameter after change to 27 WebPasteboardProxy.messages.in. Use with MESSAGE_CHECK(). 28 - Validate `size` parameter using MESSAGE_CHECK(). Because 29 SharedMemory::Handle::size() returns a size_t value, we do not 30 need to check `size <= std::numeric_limits<size_t>::max()`. 31 - Add static_cast<size_t>() to size parameter to denote type 32 change. 33 * UIProcess/WebPasteboardProxy.h: 34 (WebKit::WebPasteboardProxy::setPasteboardBufferForType): 35 - Add IPC::Connection& parameter after change to 36 WebPasteboardProxy.messages.in. 37 * UIProcess/WebPasteboardProxy.messages.in: 38 (SetPasteboardBufferForType): 39 - Add 'WantsConnection' attribute to add IPC::Connection& 40 parameter to WebPasteboardProxy::setPasteboardBufferForType(). 41 1 42 2020-03-12 Youenn Fablet <youenn@apple.com> 2 43 -
trunk/Source/WebKit/Platform/IPC/Connection.h
r258201 r258334 77 77 }; 78 78 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 \ 80 82 if (!(assertion)) { \ 81 83 ASSERT(assertion); \ 82 84 (connection)->markCurrentlyDispatchedMessageAsInvalid(); \ 85 { completion; } \ 83 86 return; \ 84 87 } \ -
trunk/Source/WebKit/Platform/SharedMemory.h
r251765 r258334 73 73 74 74 bool isNull() const; 75 76 #if OS(DARWIN) || OS(WINDOWS) 77 size_t size() const { return m_size; } 78 #endif 75 79 76 80 void clear(); -
trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm
r258240 r258334 27 27 #import "WebPasteboardProxy.h" 28 28 29 #import "Connection.h" 29 30 #import "SandboxExtension.h" 30 31 #import "WebProcessProxy.h" … … 35 36 #import <WebCore/SharedBuffer.h> 36 37 #import <wtf/URL.h> 38 39 #define MESSAGE_CHECK(assertion, completion) MESSAGE_CHECK_COMPLETION_BASE(assertion, (&connection), completion) 37 40 38 41 namespace WebKit { … … 172 175 } 173 176 174 void WebPasteboardProxy::setPasteboardBufferForType( const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle& handle, uint64_t size, CompletionHandler<void(int64_t)>&& completionHandler)177 void WebPasteboardProxy::setPasteboardBufferForType(IPC::Connection& connection, const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle& handle, uint64_t size, CompletionHandler<void(int64_t)>&& completionHandler) 175 178 { 176 179 ASSERT(!pasteboardType.isNull()); … … 180 183 if (handle.isNull()) 181 184 return completionHandler(PlatformPasteboard(pasteboardName).setBufferForType(nullptr, pasteboardType)); 185 186 // SharedMemory::Handle::size() is rounded up to the nearest page. 187 MESSAGE_CHECK(size && size <= handle.size(), completionHandler(0)); 188 182 189 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::map(handle, SharedMemory::Protection::ReadOnly); 183 190 if (!sharedMemoryBuffer) 184 191 return completionHandler(0); 185 auto buffer = SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), s ize);192 auto buffer = SharedBuffer::create(static_cast<unsigned char *>(sharedMemoryBuffer->data()), static_cast<size_t>(size)); 186 193 completionHandler(PlatformPasteboard(pasteboardName).setBufferForType(buffer.ptr(), pasteboardType)); 187 194 } … … 288 295 289 296 } // namespace WebKit 297 298 #undef MESSAGE_CHECK -
trunk/Source/WebKit/UIProcess/WebPasteboardProxy.h
r257145 r258334 93 93 void setPasteboardColor(const String&, const WebCore::Color&, CompletionHandler<void(int64_t)>&&); 94 94 void setPasteboardStringForType(const String& pasteboardName, const String& pasteboardType, const String&, CompletionHandler<void(int64_t)>&&); 95 void setPasteboardBufferForType( const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle&, uint64_t size, CompletionHandler<void(int64_t)>&&);95 void setPasteboardBufferForType(IPC::Connection&, const String& pasteboardName, const String& pasteboardType, const SharedMemory::Handle&, uint64_t size, CompletionHandler<void(int64_t)>&&); 96 96 #endif 97 97 -
trunk/Source/WebKit/UIProcess/WebPasteboardProxy.messages.in
r257145 r258334 56 56 SetPasteboardColor(String pasteboardName, WebCore::Color color) -> (int64_t changeCount) Synchronous 57 57 SetPasteboardStringForType(String pasteboardName, String pasteboardType, String string) -> (int64_t changeCount) Synchronous 58 SetPasteboardBufferForType(String pasteboardName, String pasteboardType, WebKit::SharedMemory::Handle handle, uint64_t size) -> (int64_t changeCount) Synchronous 58 SetPasteboardBufferForType(String pasteboardName, String pasteboardType, WebKit::SharedMemory::Handle handle, uint64_t size) -> (int64_t changeCount) Synchronous WantsConnection 59 59 #endif 60 60
Note: See TracChangeset
for help on using the changeset viewer.