Title: [258596] branches/safari-609-branch/Source/WebKit
Revision
258596
Author
[email protected]
Date
2020-03-17 14:07:03 -0700 (Tue, 17 Mar 2020)

Log Message

Apply patch. rdar://problem/60433244

Modified Paths


Diff

Modified: branches/safari-609-branch/Source/WebKit/ChangeLog (258595 => 258596)


--- branches/safari-609-branch/Source/WebKit/ChangeLog	2020-03-17 21:07:00 UTC (rev 258595)
+++ branches/safari-609-branch/Source/WebKit/ChangeLog	2020-03-17 21:07:03 UTC (rev 258596)
@@ -1,5 +1,29 @@
 2020-03-17  Alan Coon  <[email protected]>
 
+        Apply patch. rdar://problem/60433244
+
+    2020-03-17  David Kilzer  <[email protected]>
+
+            Cherry-pick r258401. rdar://problem/60433244
+
+        2020-03-13  David Kilzer  <[email protected]>
+
+            WebPageProxy::SetPromisedDataForImage should validate its `imageSize` and `archiveSize` parameters
+            <https://webkit.org/b/209029>
+            <rdar://problem/60181394>
+
+            Reviewed by Youenn Fablet.
+
+            * UIProcess/mac/WebPageProxyMac.mm:
+            (WebKit::WebPageProxy::setPromisedDataForImage):
+            - Validate `imageSize` and `archiveSize` using MESSAGE_CHECK().
+            - Add static_cast<size_t>() to `imageSize` and `archiveSize`
+              parameters to denote type change.
+            - Add nullptr check for SharedMemory::map() result with
+              `archiveHandle`.
+
+2020-03-17  Alan Coon  <[email protected]>
+
         Apply patch. rdar://problem/60436975
 
     2020-03-17  David Kilzer  <[email protected]>

Modified: branches/safari-609-branch/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm (258595 => 258596)


--- branches/safari-609-branch/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2020-03-17 21:07:00 UTC (rev 258595)
+++ branches/safari-609-branch/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2020-03-17 21:07:03 UTC (rev 258596)
@@ -315,17 +315,23 @@
     MESSAGE_CHECK_URL(url);
     MESSAGE_CHECK_URL(visibleURL);
     MESSAGE_CHECK(!imageHandle.isNull());
+    // SharedMemory::Handle::size() is rounded up to the nearest page.
+    MESSAGE_CHECK(imageSize && imageSize <= imageHandle.size());
 
-    RefPtr<SharedMemory> sharedMemoryImage = SharedMemory::map(imageHandle, SharedMemory::Protection::ReadOnly);
+    auto sharedMemoryImage = SharedMemory::map(imageHandle, SharedMemory::Protection::ReadOnly);
     if (!sharedMemoryImage)
         return;
 
-    auto imageBuffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryImage->data()), imageSize);
+    auto imageBuffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryImage->data()), static_cast<size_t>(imageSize));
     RefPtr<SharedBuffer> archiveBuffer;
-    
+
     if (!archiveHandle.isNull()) {
-        RefPtr<SharedMemory> sharedMemoryArchive = SharedMemory::map(archiveHandle, SharedMemory::Protection::ReadOnly);
-        archiveBuffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryArchive->data()), archiveSize);
+        // SharedMemory::Handle::size() is rounded up to the nearest page.
+        MESSAGE_CHECK(archiveSize && archiveSize <= archiveHandle.size());
+        auto sharedMemoryArchive = SharedMemory::map(archiveHandle, SharedMemory::Protection::ReadOnly);
+        if (!sharedMemoryArchive)
+            return;
+        archiveBuffer = SharedBuffer::create(static_cast<unsigned char*>(sharedMemoryArchive->data()), static_cast<size_t>(archiveSize));
     }
     pageClient().setPromisedDataForImage(pasteboardName, WTFMove(imageBuffer), filename, extension, title, url, visibleURL, WTFMove(archiveBuffer));
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to