[webkit-changes] [WebKit/WebKit] 2d83a1: std::filesystem::copy should not be used to recurs...
nmahendru
noreply at github.com
Fri Dec 20 11:49:15 PST 2024
Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 2d83a1557ecb11064ff28a5078f31680c4505ade
https://github.com/WebKit/WebKit/commit/2d83a1557ecb11064ff28a5078f31680c4505ade
Author: Nitin Mahendru <nitinmahendru at apple.com>
Date: 2024-12-20 (Fri, 20 Dec 2024)
Changed paths:
A LayoutTests/storage/filesystemaccess/filesystem-directory-handle-rename-expected.txt
A LayoutTests/storage/filesystemaccess/filesystem-directory-handle-rename.html
M Source/WTF/wtf/FileSystem.cpp
M Source/WTF/wtf/FileSystem.h
M Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp
Log Message:
-----------
std::filesystem::copy should not be used to recursively copy parent into it's child.
https://bugs.webkit.org/show_bug.cgi?id=281280
rdar://137177339
Reviewed by Sihui Liu and Alex Christensen.
The added test case filesystem-directory-handle-rename.html will cause std::filesystem::copy to be
called with top OPFS FileSystem directory being copied into itself under a subdirectory with name `\u0480`.
This will cause a recursive directory tree to be generated inside the root storage directory.
If FileSystem::directorySize() is called over that directory, it will abort with `Too many open files`.
The Unicode `\u0480` has no significance but just a weird character to use for the file name.
If you see this, It should raise questions. Thus the choice.
The same error will happen if we choose "anyRandomAsciiName".
The fix added here will prevent std::filesystem::copy to be called in case source is ancestor of destination.
* LayoutTests/storage/filesystemaccess/filesystem-directory-handle-rename.html: Added.
* Source/WTF/wtf/FileSystem.cpp:
(WTF::FileSystemImpl::isAncestor):
* Source/WTF/wtf/FileSystem.h:
* Source/WebKit/NetworkProcess/storage/FileSystemStorageHandle.cpp:
(WebKit::FileSystemStorageHandle::move):
* Tools/TestWebKitAPI/Tests/WTF/FileSystem.cpp:
(TestWebKitAPI::TEST_F(FileSystemTest, isAncestor)):
Originally-landed-as: 283286.251 at safari-7620-branch (30ab479e8242). rdar://141318843
Canonical link: https://commits.webkit.org/288177@main
To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications
More information about the webkit-changes
mailing list