Title: [287600] trunk/Source/WebKit
Revision
287600
Author
[email protected]
Date
2022-01-04 17:26:05 -0800 (Tue, 04 Jan 2022)

Log Message

ASSERTION FAILED: pathnames.size() == sandboxExtensionsHandleArray.size() in WebKit::WebPlatformStrategies::getPathnamesForType()
https://bugs.webkit.org/show_bug.cgi?id=234851
rdar://87100377

Reviewed by Darin Adler.

The new API test added r287547 (WKAttachmentTestsMac.InsertNonExistentImageFileAsAttachment) exercises inserting
a nonexistent file as a "progress" attachment element when the WebKit attachment API is enabled. This test is
the first on macOS that attempts to paste file paths pointing to nonexistent files on disk, and so it hits an
existing assertion due to the number of sandbox extensions opened underneath `getPasteboardPathnamesForType()`
not matching the number of file paths found on the pasteboard.

This assertion is benign, since we do not expect to be able to read from the missing file path in the web
process, so it's expected that we don't have a corresponding sandbox extension for missing files. To address
this, we adjust `WebPasteboardProxy::getPasteboardPathnamesForType()` such that it always returns an equal
number of path names and pathnames. Each missing path name simply corresponds to a `SandboxExtension::Handle`
with a null `m_sandboxExtension`, which is skipped in the web process upon consumption.

* UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
(WebKit::WebPasteboardProxy::getPasteboardPathnamesForType):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (287599 => 287600)


--- trunk/Source/WebKit/ChangeLog	2022-01-05 01:04:31 UTC (rev 287599)
+++ trunk/Source/WebKit/ChangeLog	2022-01-05 01:26:05 UTC (rev 287600)
@@ -1,3 +1,26 @@
+2022-01-04  Wenson Hsieh  <[email protected]>
+
+        ASSERTION FAILED: pathnames.size() == sandboxExtensionsHandleArray.size() in WebKit::WebPlatformStrategies::getPathnamesForType()
+        https://bugs.webkit.org/show_bug.cgi?id=234851
+        rdar://87100377
+
+        Reviewed by Darin Adler.
+
+        The new API test added r287547 (WKAttachmentTestsMac.InsertNonExistentImageFileAsAttachment) exercises inserting
+        a nonexistent file as a "progress" attachment element when the WebKit attachment API is enabled. This test is
+        the first on macOS that attempts to paste file paths pointing to nonexistent files on disk, and so it hits an
+        existing assertion due to the number of sandbox extensions opened underneath `getPasteboardPathnamesForType()`
+        not matching the number of file paths found on the pasteboard.
+
+        This assertion is benign, since we do not expect to be able to read from the missing file path in the web
+        process, so it's expected that we don't have a corresponding sandbox extension for missing files. To address
+        this, we adjust `WebPasteboardProxy::getPasteboardPathnamesForType()` such that it always returns an equal
+        number of path names and pathnames. Each missing path name simply corresponds to a `SandboxExtension::Handle`
+        with a null `m_sandboxExtension`, which is skipped in the web process upon consumption.
+
+        * UIProcess/Cocoa/WebPasteboardProxyCocoa.mm:
+        (WebKit::WebPasteboardProxy::getPasteboardPathnamesForType):
+
 2022-01-04  Ryan Haddad  <[email protected]>
 
         Unreviewed, reverting r287374.

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm (287599 => 287600)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm	2022-01-05 01:04:31 UTC (rev 287599)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebPasteboardProxyCocoa.mm	2022-01-05 01:26:05 UTC (rev 287600)
@@ -171,15 +171,14 @@
         Vector<SandboxExtension::Handle> sandboxExtensions;
         if (webProcessProxyForConnection(connection)) {
             PlatformPasteboard(pasteboardName).getPathnamesForType(pathnames, pasteboardType);
+            // On iOS, files are copied into app's container upon paste.
 #if PLATFORM(MAC)
-            // On iOS, files are copied into app's container upon paste.
-            for (size_t i = 0; i < pathnames.size(); i++) {
-                auto& filename = pathnames[i];
+            sandboxExtensions = pathnames.map([](auto& filename) {
                 if (![[NSFileManager defaultManager] fileExistsAtPath:filename])
-                    continue;
-                if (auto handle = SandboxExtension::createHandle(filename, SandboxExtension::Type::ReadOnly))
-                    sandboxExtensions.append(WTFMove(*handle));
-            }
+                    return SandboxExtension::Handle { };
+
+                return SandboxExtension::createHandle(filename, SandboxExtension::Type::ReadOnly).value_or(SandboxExtension::Handle { });
+            });
 #endif
         }
         completionHandler(WTFMove(pathnames), WTFMove(sandboxExtensions));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to