Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3187)

Unified Diff: chrome/browser/safe_browsing/safe_browsing_database.cc

Issue 10093004: Double-check safe-browsing database validity on update failure. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Check size before reading. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/safe_browsing_store.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/safe_browsing/safe_browsing_database.cc
diff --git a/chrome/browser/safe_browsing/safe_browsing_database.cc b/chrome/browser/safe_browsing/safe_browsing_database.cc
index d880472c87d1390244188cf27dd1eccd09a09ecf..31cac5078dc8976ff0711add57a576f95e455414 100644
--- a/chrome/browser/safe_browsing/safe_browsing_database.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_database.cc
@@ -1101,6 +1101,29 @@ bool SafeBrowsingDatabaseNew::UpdateStarted(
void SafeBrowsingDatabaseNew::UpdateFinished(bool update_succeeded) {
DCHECK_EQ(creation_loop_, MessageLoop::current());
+
+ // The update may have failed due to corrupt storage (for instance,
+ // an excessive number of invalid add_chunks and sub_chunks).
+ // Double-check that the databases are valid.
+ // TODO(shess): Providing a checksum for the add_chunk and sub_chunk
+ // sections would allow throwing a corruption error in
+ // UpdateStarted().
+ if (!update_succeeded) {
+ if (!browse_store_->CheckValidity())
+ DLOG(ERROR) << "Safe-browsing browse database corrupt.";
+
+ if (download_store_.get() && !download_store_->CheckValidity())
+ DLOG(ERROR) << "Safe-browsing download database corrupt.";
+
+ if (csd_whitelist_store_.get() && !csd_whitelist_store_->CheckValidity())
+ DLOG(ERROR) << "Safe-browsing csd whitelist database corrupt.";
+
+ if (download_whitelist_store_.get() &&
+ !download_whitelist_store_->CheckValidity()) {
+ DLOG(ERROR) << "Safe-browsing download whitelist database corrupt.";
+ }
+ }
+
if (corruption_detected_)
return;
@@ -1325,7 +1348,7 @@ void SafeBrowsingDatabaseNew::OnHandleCorruptDatabase() {
RecordFailure(FAILURE_DATABASE_CORRUPT_HANDLER);
corruption_detected_ = true; // Stop updating the database.
ResetDatabase();
- DCHECK(false) << "SafeBrowsing database was corrupt and reset";
+ DLOG(FATAL) << "SafeBrowsing database was corrupt and reset";
}
// TODO(shess): I'm not clear why this code doesn't have any
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/safe_browsing_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698