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

Unified Diff: net/disk_cache/simple/simple_synchronous_entry.cc

Issue 2878533002: SimpleCache: Tolerate weird file sizes when doing index recovery. (Closed)
Patch Set: Woops, the test was meant to be a different CL. Created 3 years, 7 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 | « net/disk_cache/simple/simple_index_file.cc ('k') | tools/metrics/histograms/enums.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/simple/simple_synchronous_entry.cc
diff --git a/net/disk_cache/simple/simple_synchronous_entry.cc b/net/disk_cache/simple/simple_synchronous_entry.cc
index 2b4673c2384d29ff8082a912c0c441404daca107..dc27812c71382e95de0430d79a699a080174899d 100644
--- a/net/disk_cache/simple/simple_synchronous_entry.cc
+++ b/net/disk_cache/simple/simple_synchronous_entry.cc
@@ -43,7 +43,8 @@ enum OpenEntryResult {
OPEN_ENTRY_KEY_MISMATCH = 6,
OPEN_ENTRY_KEY_HASH_MISMATCH = 7,
OPEN_ENTRY_SPARSE_OPEN_FAILED = 8,
- OPEN_ENTRY_MAX = 9,
+ OPEN_ENTRY_INVALID_FILE_LENGTH = 9,
+ OPEN_ENTRY_MAX = 10,
};
// Used in histograms, please only add entries at the end.
@@ -951,6 +952,11 @@ bool SimpleSynchronousEntry::OpenFiles(SimpleEntryStat* out_entry_stat) {
// 0, stream 1 and one EOF record. The exact distribution of sizes between
// stream 1 and stream 0 is only determined after reading the EOF record
// for stream 0 in ReadAndValidateStream0.
+ if (!base::IsValueInRangeForNumericType<int>(file_info.size)) {
+ RecordSyncOpenResult(cache_type_, OPEN_ENTRY_INVALID_FILE_LENGTH,
+ had_index_);
+ return false;
+ }
out_entry_stat->set_data_size(i + 1, static_cast<int>(file_info.size));
}
SIMPLE_CACHE_UMA(CUSTOM_COUNTS,
« no previous file with comments | « net/disk_cache/simple/simple_index_file.cc ('k') | tools/metrics/histograms/enums.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698