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

Unified Diff: components/safe_browsing_db/v4_store.h

Issue 2384893002: PVer4: Test checksum on startup outside the hotpath of DB load (Closed)
Patch Set: Created 4 years, 3 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 | components/safe_browsing_db/v4_store.cc » ('j') | components/safe_browsing_db/v4_store.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/safe_browsing_db/v4_store.h
diff --git a/components/safe_browsing_db/v4_store.h b/components/safe_browsing_db/v4_store.h
index d4559780cae063ccfeae55d8a14f29f33bff8082..457a995eb525ff13d5a4d48cfe3ffec5e0e2b3a5 100644
--- a/components/safe_browsing_db/v4_store.h
+++ b/components/safe_browsing_db/v4_store.h
@@ -246,6 +246,7 @@ class V4Store {
FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestAdditionsWithRiceEncodingSucceeds);
FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestRemovalsWithRiceEncodingSucceeds);
FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestMergeUpdatesFailsChecksum);
+ FRIEND_TEST_ALL_PREFIXES(V4StoreTest, TestChecksumErrorOnStartup);
friend class V4StoreTest;
// If |prefix_size| is within expected range, and |raw_hashes_length| is a
@@ -299,8 +300,9 @@ class V4Store {
// Merges the prefix map from the old store (|old_hash_prefix_map|) and the
// update (additions_map) to populate the prefix map for the current store.
// The indices in the |raw_removals| list, which may be NULL, are not merged.
- // The SHA256 checksum of the final list of hash prefixes, in lexographically
- // sorted order, must match |expected_checksum| (if it's not empty).
+ // The SHA256 checksum of the final list of hash prefixes, in
+ // lexicographically sorted order, must match |expected_checksum| (if it's not
+ // empty).
ApplyUpdateResult MergeUpdate(const HashPrefixMap& old_hash_prefix_map,
const HashPrefixMap& additions_map,
const ::google::protobuf::RepeatedField<
@@ -341,6 +343,12 @@ class V4Store {
// for the failure or reports success.
StoreReadResult ReadFromDisk();
+ // Scheduled when reading the store file from disk on startup. When run, it
+ // ensures that the checksum of the hash prefixes in lexicographical sorted
+ // order matches the expected value. If not, it clears out the contents of
+ // the store.
+ void VerifyChecksum(const std::string& expected_checksum);
+
// Writes the FULL_UPDATE |response| to disk as a V4StoreFileFormat proto.
StoreWriteResult WriteToDisk(
std::unique_ptr<ListUpdateResponse> response) const;
« no previous file with comments | « no previous file | components/safe_browsing_db/v4_store.cc » ('j') | components/safe_browsing_db/v4_store.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698