Skip to content
Permalink
Browse files
ASSERTION FAILED: pathnames.size() == sandboxExtensionsHandleArray.si…
…ze() 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):



Canonical link: https://commits.webkit.org/245728@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287600 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
whsieh committed Jan 5, 2022
1 parent 6a6a513 commit c72be96ad465b714b863f1800f9faa2baca2da47
Showing 2 changed files with 29 additions and 7 deletions.
@@ -1,3 +1,26 @@
2022-01-04 Wenson Hsieh <wenson_hsieh@apple.com>

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 <ryanhaddad@apple.com>

Unreviewed, reverting r287374.
@@ -171,15 +171,14 @@
Vector<SandboxExtension::Handle> sandboxExtensions;
if (webProcessProxyForConnection(connection)) {
PlatformPasteboard(pasteboardName).getPathnamesForType(pathnames, pasteboardType);
#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];
#if PLATFORM(MAC)
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));

0 comments on commit c72be96

Please sign in to comment.