Changeset 228971 in webkit


Ignore:
Timestamp:
Feb 23, 2018 6:01:36 PM (6 years ago)
Author:
commit-queue@webkit.org
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.reid@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:
Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r228954 r228971  
     12018-02-23  Christopher Reid  <chris.reid@sony.com>
     2
     3        [Curl] Cookie Database files are wrongfully getting deleted when the database is opened
     4        https://bugs.webkit.org/show_bug.cgi?id=183051
     5
     6        Reviewed by Per Arne Vollan.
     7
     8        The file stat logic was backwards causing a wrongful detection of database corruption.
     9        Fixed the logic and abstracted these calls to use FileSystem.
     10
     11        * platform/network/curl/CookieJarDB.cpp:
     12
    1132018-02-23  Zalan Bujtas  <zalan@apple.com>
    214
  • trunk/Source/WebCore/platform/network/curl/CookieJarDB.cpp

    r228905 r228971  
    173173        return;
    174174
    175     FILE* f = fopen(getCorruptionMarkerPath().utf8().data(), "wb");
    176     fclose(f);
     175    auto handle = FileSystem::openFile(getCorruptionMarkerPath(), FileSystem::FileOpenMode::Write);
     176    if (FileSystem::isHandleValid(handle))
     177        FileSystem::closeFile(handle);
    177178}
    178179
    179180bool CookieJarDB::checkDatabaseCorruptionAndRemoveIfNeeded()
    180181{
    181     if (isOnMemory())
    182         return false;
    183 
    184     struct stat st;
    185     int ret = stat(getCorruptionMarkerPath().utf8().data(), &st);
    186     if (!ret)
    187         return false;
    188 
    189     deleteAllDatabaseFiles();
    190     return true;
     182    if (!isOnMemory() && FileSystem::fileExists(getCorruptionMarkerPath())) {
     183        deleteAllDatabaseFiles();
     184        return true;
     185    }
     186
     187    return false;
    191188}
    192189
Note: See TracChangeset for help on using the changeset viewer.