WebKit Bugzilla
Attachment 341007 Details for
Bug 185873
: [Curl] Not all Cookie database files are deleted on corruption
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
185873.diff (text/plain), 4.98 KB, created by
Christopher Reid
on 2018-05-22 12:44:19 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Christopher Reid
Created:
2018-05-22 12:44:19 PDT
Size:
4.98 KB
patch
obsolete
>diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 3b01181ae06..248141bbc77 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,18 @@ >+2018-05-22 Christopher Reid <chris.reid@sony.com> >+ >+ [Curl] Not all Cookie database files are deleted on corruption >+ https://bugs.webkit.org/show_bug.cgi?id=185873 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ No new tests. >+ >+ Delete the cookie database file and the corruption flag file when corruption is detected. >+ Adding a quick integrity check in case it can catch anything when opening the database. >+ Removing PRAGMA temp_store = MEMORY and PRAGMA journal_mode = WAL as they are set in SQLiteDatabase::open. >+ >+ * platform/network/curl/CookieJarDB.cpp: >+ > 2018-05-18 Basuke Suzuki <Basuke.Suzuki@sony.com> > > [Curl] Bug fix on suspend/resume behavior. >diff --git a/Source/WebCore/platform/network/curl/CookieJarDB.cpp b/Source/WebCore/platform/network/curl/CookieJarDB.cpp >index ee52b50d7f8..5ed3e31242a 100644 >--- a/Source/WebCore/platform/network/curl/CookieJarDB.cpp >+++ b/Source/WebCore/platform/network/curl/CookieJarDB.cpp >@@ -107,11 +107,13 @@ bool CookieJarDB::openDatabase() > executeSimpleSql(DELETE_ALL_SESSION_COOKIE_SQL); > else { > // delete database and try to re-create again >+ LOG_ERROR("Cookie database validity check failed, attempting to recreate the database"); > m_database.close(); > deleteAllDatabaseFiles(); > existsDatabaseFile = false; > } > } else { >+ LOG_ERROR("Failed to open cookie database: %s, attempting to recreate the database", m_databasePath.utf8().data()); > deleteAllDatabaseFiles(); > existsDatabaseFile = false; > } >@@ -137,9 +139,7 @@ bool CookieJarDB::openDatabase() > if (!m_database.isOpen()) > return false; > >- executeSimpleSql("PRAGMA temp_store = MEMORY;"); >- executeSimpleSql("PRAGMA synchronous = NORMAL;"); >- executeSimpleSql("PRAGMA journal_mode = WAL;"); >+ m_database.setSynchronous(SQLiteDatabase::SyncNormal); > > // create prepared statements > createPrepareStatement(SET_COOKIE_SQL); >@@ -180,6 +180,7 @@ void CookieJarDB::flagDatabaseCorruption() > bool CookieJarDB::checkDatabaseCorruptionAndRemoveIfNeeded() > { > if (!isOnMemory() && FileSystem::fileExists(getCorruptionMarkerPath())) { >+ LOG_ERROR("Detected cookie database corruption, attempting to recreate the database"); > deleteAllDatabaseFiles(); > return true; > } >@@ -207,7 +208,32 @@ bool CookieJarDB::checkDatabaseValidity() > { > ASSERT(m_database.isOpen()); > >- return m_database.tableExists("Cookie"); >+ if (!m_database.tableExists("Cookie")) >+ return false; >+ >+ SQLiteStatement integrity(m_database, "PRAGMA quick_check;"); >+ if (integrity.prepare() != SQLITE_OK) { >+ LOG_ERROR("Failed to execute database integrity check"); >+ return false; >+ } >+ >+ int resultCode = integrity.step(); >+ if (resultCode == SQLITE_OK) >+ return true; >+ >+ int columns = integrity.columnCount(); >+ if (columns != 1) { >+ LOG_ERROR("Received %i columns performing integrity check, should be 1", columns); >+ return false; >+ } >+ >+ String resultText = integrity.getColumnText(0); >+ >+ if (resultText == "ok") >+ return true; >+ >+ LOG_ERROR("Cookie database integrity check failed - %s", resultText.ascii().data()); >+ return false; > } > > void CookieJarDB::deleteAllDatabaseFiles() >@@ -216,19 +242,11 @@ void CookieJarDB::deleteAllDatabaseFiles() > if (isOnMemory()) > return; > >- int ret = 0; >- String removePath; >- >- // remove marker file (cookie.jar.db-corrupted) >- ret = remove(removePath.utf8().data()); >- >- // remove shm file (cookie.jar.db-shm) >- removePath = String(m_databasePath + "-shm"); >- ret = remove(removePath.utf8().data()); >- >- // remove wal file (cookie.jar.db-wal) >- removePath = String(m_databasePath + "-wal"); >- ret = remove(removePath.utf8().data()); >+ FileSystem::deleteFile(m_databasePath); >+ FileSystem::deleteFile(getCorruptionMarkerPath()); >+ FileSystem::deleteFile(m_databasePath + "-shm"); >+ FileSystem::deleteFile(m_databasePath + "-wal"); >+ FileSystem::deleteFile(m_databasePath + "-shm"); > } > > bool CookieJarDB::isEnabled() >@@ -484,10 +502,12 @@ int CookieJarDB::executeSimpleSql(const char* sql, bool ignoreError) > int ret = statement.prepareAndStep(); > statement.finalize(); > >- ASSERT(checkSQLiteReturnCode(ret, SQLITE_OK) >- || checkSQLiteReturnCode(ret, SQLITE_DONE) >- || checkSQLiteReturnCode(ret, SQLITE_ROW) >- || ignoreError); >+ if (!checkSQLiteReturnCode(ret, SQLITE_OK) >+ && !checkSQLiteReturnCode(ret, SQLITE_DONE) >+ && !checkSQLiteReturnCode(ret, SQLITE_ROW) >+ && !ignoreError) >+ LOG_ERROR("Failed to execute %s error: %s", sql, m_database.lastErrorMsg()); >+ > return ret; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
Hironori.Fujii
:
review-
ews-watchlist
:
commit-queue-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 185873
:
341007
|
341032
|
347252