From: cdumez@apple.com Date: Sat, 20 Jan 2018 10:43:38 +0000 (+0000) Subject: DOMCache data sometimes not properly removed when clearing data for a given origin X-Git-Url: http://git.webkit.org/?p=WebKit-https.git;a=commitdiff_plain;h=1e61933e252b161cfa4504a2ae4134aad72644b4 DOMCache data sometimes not properly removed when clearing data for a given origin https://bugs.webkit.org/show_bug.cgi?id=181887 Reviewed by Youenn Fablet. * NetworkProcess/cache/CacheStorageEngine.cpp: (WebKit::CacheStorage::Engine::clearCachesForOrigin): This code was iterating through folders on disk, then reading the folder's origin from the origin file on disk. Then, if the origin would match the one we want to delete, it would regenerate the folder path using cachesRootPath(*folderOrigin). I don't know how but on my machine, I was ended up in a state where the path generated by cachesRootPath(*folderOrigin) differed from the actual folder path we read the origin from (Likely a different salt?). To make the code more robust, I updated the code to delete "folderPath", which is the path we read the origin from. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@227269 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog index 409cc34..c48c755 100644 --- a/Source/WebKit/ChangeLog +++ b/Source/WebKit/ChangeLog @@ -1,3 +1,22 @@ +2018-01-20 Chris Dumez + + DOMCache data sometimes not properly removed when clearing data for a given origin + https://bugs.webkit.org/show_bug.cgi?id=181887 + + + Reviewed by Youenn Fablet. + + * NetworkProcess/cache/CacheStorageEngine.cpp: + (WebKit::CacheStorage::Engine::clearCachesForOrigin): + This code was iterating through folders on disk, then reading the folder's origin + from the origin file on disk. Then, if the origin would match the one we want to + delete, it would regenerate the folder path using cachesRootPath(*folderOrigin). + I don't know how but on my machine, I was ended up in a state where the path + generated by cachesRootPath(*folderOrigin) differed from the actual folder path + we read the origin from (Likely a different salt?). To make the code more robust, + I updated the code to delete "folderPath", which is the path we read the origin + from. + 2018-01-19 Zach Li Expose Safe Browsing SPI diff --git a/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp b/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp index ba72703..cf078f1 100644 --- a/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp +++ b/Source/WebKit/NetworkProcess/cache/CacheStorageEngine.cpp @@ -414,13 +414,13 @@ void Engine::clearCachesForOrigin(const WebCore::SecurityOriginData& origin, Cal for (auto& folderPath : WebCore::FileSystem::listDirectory(m_rootPath, "*")) { if (!WebCore::FileSystem::fileIsDirectory(folderPath, WebCore::FileSystem::ShouldFollowSymbolicLinks::No)) continue; - Caches::retrieveOriginFromDirectory(folderPath, *m_ioQueue, [this, protectedThis = makeRef(*this), origin, taskHandler = makeRef(taskHandler)] (std::optional&& folderOrigin) mutable { + Caches::retrieveOriginFromDirectory(folderPath, *m_ioQueue, [this, protectedThis = makeRef(*this), origin, taskHandler = makeRef(taskHandler), folderPath] (std::optional&& folderOrigin) mutable { if (!folderOrigin) return; if (folderOrigin->topOrigin != origin && folderOrigin->clientOrigin != origin) return; - m_ioQueue->dispatch([path = cachesRootPath(*folderOrigin), taskHandler = WTFMove(taskHandler)] { + m_ioQueue->dispatch([path = folderPath.isolatedCopy(), taskHandler = WTFMove(taskHandler)] { deleteDirectoryRecursively(path); }); });