Changeset 245009 in webkit
- Timestamp:
- May 7, 2019 7:39:10 AM (5 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r245008 r245009 1 2019-05-07 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [macOS] Avoid crashing the UI process when writing empty data to the pasteboard 4 https://bugs.webkit.org/show_bug.cgi?id=197644 5 <rdar://problem/50526364> 6 7 Reviewed by Tim Horton. 8 9 Test: WebKit.WKWebProcessPlugInDoNotCrashWhenCopyingEmptyClientData 10 11 * WebProcess/WebCoreSupport/WebPlatformStrategies.cpp: 12 (WebKit::WebPlatformStrategies::setBufferForType): 13 14 Make this function robust by not attempting to create a shared memory buffer in the case where the given data 15 buffer is empty. 16 1 17 2019-05-07 Carlos Garcia Campos <cgarcia@igalia.com> 2 18 -
trunk/Source/WebKit/WebProcess/WebCoreSupport/WebPlatformStrategies.cpp
r241749 r245009 203 203 { 204 204 SharedMemory::Handle handle; 205 if (buffer ) {205 if (buffer && buffer->size()) { 206 206 RefPtr<SharedMemory> sharedMemoryBuffer = SharedMemory::allocate(buffer->size()); 207 207 // FIXME: Null check prevents crashing, but it is not great that we will have empty pasteboard content for this type, -
trunk/Tools/ChangeLog
r245007 r245009 1 2019-05-07 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 [macOS] Avoid crashing the UI process when writing empty data to the pasteboard 4 https://bugs.webkit.org/show_bug.cgi?id=197644 5 <rdar://problem/50526364> 6 7 Reviewed by Tim Horton. 8 9 Add a new API test to exercise a possible scenario where we may crash while writing data to the pasteboard. 10 11 * TestWebKitAPI/Tests/WebKitCocoa/BundleEditingDelegate.mm: 12 * TestWebKitAPI/Tests/WebKitCocoa/BundleEditingDelegatePlugIn.mm: 13 (-[BundleEditingDelegatePlugIn webProcessPlugIn:didCreateBrowserContextController:]): 14 (-[BundleEditingDelegatePlugIn _webProcessPlugInBrowserContextController:pasteboardDataForRange:]): 15 1 16 2019-05-07 Carlos Garcia Campos <cgarcia@igalia.com> 2 17 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/BundleEditingDelegate.mm
r242339 r245009 116 116 } 117 117 118 #endif 118 TEST(WebKit, WKWebProcessPlugInDoNotCrashWhenCopyingEmptyClientData) 119 { 120 auto configuration = retainPtr([WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"BundleEditingDelegatePlugIn"]); 121 [[configuration processPool] _setObject:@YES forBundleParameter:@"EditingDelegateShouldWriteEmptyData"]; 122 123 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); 124 [webView loadHTMLString:@"<body style='-webkit-user-modify: read-write-plaintext-only'>Just something to copy <script> var textNode = document.body.firstChild; document.getSelection().setBaseAndExtent(textNode, 5, textNode, 14) </script>" baseURL:nil]; 125 [webView _test_waitForDidFinishNavigation]; 126 127 auto object = adoptNS([[BundleEditingDelegateRemoteObject alloc] init]); 128 _WKRemoteObjectInterface *interface = [_WKRemoteObjectInterface remoteObjectInterfaceWithProtocol:@protocol(BundleEditingDelegateProtocol)]; 129 [[webView _remoteObjectRegistry] registerExportedObject:object.get() interface:interface]; 130 131 [webView performSelector:@selector(copy:) withObject:nil]; 132 TestWebKitAPI::Util::run(&didWriteToPasteboard); 133 } 134 135 #endif // PLATFORM(MAC) -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/BundleEditingDelegatePlugIn.mm
r242339 r245009 46 46 BOOL _editingDelegateShouldInsertText; 47 47 BOOL _shouldOverridePerformTwoStepDrop; 48 BOOL _shouldWriteEmptyData; 48 49 } 49 50 … … 61 62 _editingDelegateShouldInsertText = YES; 62 63 64 _shouldWriteEmptyData = [[plugInController.parameters valueForKey:@"EditingDelegateShouldWriteEmptyData"] boolValue]; 63 65 _shouldOverridePerformTwoStepDrop = [[plugInController.parameters valueForKey:@"BundleOverridePerformTwoStepDrop"] boolValue]; 64 66 … … 84 86 - (NSDictionary<NSString *, NSData *> *)_webProcessPlugInBrowserContextController:(WKWebProcessPlugInBrowserContextController *)controller pasteboardDataForRange:(WKWebProcessPlugInRangeHandle *)range 85 87 { 86 return @{ @"org.webkit.data" : [NSData dataWithBytesNoCopy:(void*)"hello" length:5 freeWhenDone:NO] };88 return @{ @"org.webkit.data" : _shouldWriteEmptyData ? NSData.data : [NSData dataWithBytesNoCopy:(void*)"hello" length:5 freeWhenDone:NO] }; 87 89 } 88 90
Note: See TracChangeset
for help on using the changeset viewer.