Title: [228971] trunk/Source/WebCore
Revision
228971
Author
commit-qu...@webkit.org
Date
2018-02-23 18:01:36 -0800 (Fri, 23 Feb 2018)

Log Message

[Curl] Cookie Database files are wrongfully getting deleted when the database is opened
https://bugs.webkit.org/show_bug.cgi?id=183051

Patch by Christopher Reid <chris.r...@sony.com> on 2018-02-23
Reviewed by Per Arne Vollan.

The file stat logic was backwards causing a wrongful detection of database corruption.
Fixed the logic and abstracted these calls to use FileSystem.

* platform/network/curl/CookieJarDB.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (228970 => 228971)


--- trunk/Source/WebCore/ChangeLog	2018-02-24 01:20:39 UTC (rev 228970)
+++ trunk/Source/WebCore/ChangeLog	2018-02-24 02:01:36 UTC (rev 228971)
@@ -1,3 +1,15 @@
+2018-02-23  Christopher Reid  <chris.r...@sony.com>
+
+        [Curl] Cookie Database files are wrongfully getting deleted when the database is opened
+        https://bugs.webkit.org/show_bug.cgi?id=183051
+
+        Reviewed by Per Arne Vollan.
+
+        The file stat logic was backwards causing a wrongful detection of database corruption.
+        Fixed the logic and abstracted these calls to use FileSystem.
+
+        * platform/network/curl/CookieJarDB.cpp:
+
 2018-02-23  Zalan Bujtas  <za...@apple.com>
 
         [RenderTreeBuilder] Make RenderTreeBuilder::* classes WTF_MAKE_FAST_ALLOCATED

Modified: trunk/Source/WebCore/platform/network/curl/CookieJarDB.cpp (228970 => 228971)


--- trunk/Source/WebCore/platform/network/curl/CookieJarDB.cpp	2018-02-24 01:20:39 UTC (rev 228970)
+++ trunk/Source/WebCore/platform/network/curl/CookieJarDB.cpp	2018-02-24 02:01:36 UTC (rev 228971)
@@ -172,22 +172,19 @@
     if (isOnMemory())
         return;
 
-    FILE* f = fopen(getCorruptionMarkerPath().utf8().data(), "wb");
-    fclose(f);
+    auto handle = FileSystem::openFile(getCorruptionMarkerPath(), FileSystem::FileOpenMode::Write);
+    if (FileSystem::isHandleValid(handle))
+        FileSystem::closeFile(handle);
 }
 
 bool CookieJarDB::checkDatabaseCorruptionAndRemoveIfNeeded()
 {
-    if (isOnMemory())
-        return false;
+    if (!isOnMemory() && FileSystem::fileExists(getCorruptionMarkerPath())) {
+        deleteAllDatabaseFiles();
+        return true;
+    }
 
-    struct stat st;
-    int ret = stat(getCorruptionMarkerPath().utf8().data(), &st);
-    if (!ret)
-        return false;
-
-    deleteAllDatabaseFiles();
-    return true;
+    return false;
 }
 
 bool CookieJarDB::checkSQLiteReturnCode(int actual, int expected)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to