REGRESSION(2.27.2): [GTK] Incognito mode is broken under flatpak
https://bugs.webkit.org/show_bug.cgi?id=203460
Reviewed by Youenn Fablet.
The problem is that in ephemeral sessions the base disk cache directory is null, and Storage::open() ends up
building a cache path with only the version part (/Version n). For some reason g_mkdir_with_parents() doesn't
return -1 in flatpak when it fails to create the directory due to write permission, like in this case. But the
network process ends up crashing later trying to open a directory that doesn't exist.
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::NetworkSession): Do not create the cache if networkCacheDirectory is null.
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::open): Add an ASSERT to ensure we don't receive a null baseCachePath.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@252880 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog
index e579aeb..8e4d080 100644
--- a/Source/WebKit/ChangeLog
+++ b/Source/WebKit/ChangeLog
@@ -1,3 +1,20 @@
+2019-11-26 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ REGRESSION(2.27.2): [GTK] Incognito mode is broken under flatpak
+ https://bugs.webkit.org/show_bug.cgi?id=203460
+
+ Reviewed by Youenn Fablet.
+
+ The problem is that in ephemeral sessions the base disk cache directory is null, and Storage::open() ends up
+ building a cache path with only the version part (/Version n). For some reason g_mkdir_with_parents() doesn't
+ return -1 in flatpak when it fails to create the directory due to write permission, like in this case. But the
+ network process ends up crashing later trying to open a directory that doesn't exist.
+
+ * NetworkProcess/NetworkSession.cpp:
+ (WebKit::NetworkSession::NetworkSession): Do not create the cache if networkCacheDirectory is null.
+ * NetworkProcess/cache/NetworkCacheStorage.cpp:
+ (WebKit::NetworkCache::Storage::open): Add an ASSERT to ensure we don't receive a null baseCachePath.
+
2019-11-25 Yusuke Suzuki <ysuzuki@apple.com>
[JSC] InternalFunction should be non-destructible
diff --git a/Source/WebKit/NetworkProcess/NetworkSession.cpp b/Source/WebKit/NetworkProcess/NetworkSession.cpp
index bff9ba7..9193f88 100644
--- a/Source/WebKit/NetworkProcess/NetworkSession.cpp
+++ b/Source/WebKit/NetworkProcess/NetworkSession.cpp
@@ -87,22 +87,23 @@
{
if (!m_sessionID.isEphemeral()) {
String networkCacheDirectory = parameters.networkCacheDirectory;
- if (!networkCacheDirectory.isNull())
+ if (!networkCacheDirectory.isNull()) {
SandboxExtension::consumePermanently(parameters.networkCacheDirectoryExtensionHandle);
- auto cacheOptions = networkProcess.cacheOptions();
+ auto cacheOptions = networkProcess.cacheOptions();
#if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION)
- if (parameters.networkCacheSpeculativeValidationEnabled)
- cacheOptions.add(NetworkCache::CacheOption::SpeculativeRevalidation);
+ if (parameters.networkCacheSpeculativeValidationEnabled)
+ cacheOptions.add(NetworkCache::CacheOption::SpeculativeRevalidation);
#endif
- if (parameters.shouldUseTestingNetworkSession)
- cacheOptions.add(NetworkCache::CacheOption::TestingMode);
+ if (parameters.shouldUseTestingNetworkSession)
+ cacheOptions.add(NetworkCache::CacheOption::TestingMode);
- m_cache = NetworkCache::Cache::open(networkProcess, networkCacheDirectory, cacheOptions, m_sessionID);
+ m_cache = NetworkCache::Cache::open(networkProcess, networkCacheDirectory, cacheOptions, m_sessionID);
- if (!m_cache)
- RELEASE_LOG_ERROR(NetworkCache, "Failed to initialize the WebKit network disk cache");
-
+ if (!m_cache)
+ RELEASE_LOG_ERROR(NetworkCache, "Failed to initialize the WebKit network disk cache");
+ }
+
if (!parameters.resourceLoadStatisticsDirectory.isEmpty())
SandboxExtension::consumePermanently(parameters.resourceLoadStatisticsDirectoryExtensionHandle);
}
diff --git a/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp b/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp
index a0186a4..5fc630d 100644
--- a/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp
+++ b/Source/WebKit/NetworkProcess/cache/NetworkCacheStorage.cpp
@@ -177,6 +177,7 @@
RefPtr<Storage> Storage::open(const String& baseCachePath, Mode mode)
{
ASSERT(RunLoop::isMain());
+ ASSERT(!baseCachePath.isNull());
auto cachePath = makeCachePath(baseCachePath);