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

Unified Diff: net/disk_cache/entry_unittest.cc

Issue 2086053003: Simple Cache: validate lengths before allocations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
Index: net/disk_cache/entry_unittest.cc
diff --git a/net/disk_cache/entry_unittest.cc b/net/disk_cache/entry_unittest.cc
index e9c701dcdc1d0513f11876eae7867ece4f719626..d0e2d4006132defec92dd352d9efc5c930431eec 100644
--- a/net/disk_cache/entry_unittest.cc
+++ b/net/disk_cache/entry_unittest.cc
@@ -4265,3 +4265,21 @@ TEST_F(DiskCacheEntryTest, SimpleCacheReadCorruptKeySHA256) {
disk_cache::simple_util::CorruptKeySHA256FromEntry(key, cache_path_));
EXPECT_NE(net::OK, OpenEntry(key, &entry));
}
+
+TEST_F(DiskCacheEntryTest, SimpleCacheReadCorruptLength) {
+ SetCacheType(net::APP_CACHE);
+ SetSimpleCacheMode();
+ InitCache();
+ disk_cache::Entry* entry;
+ std::string key("a key");
+ ASSERT_EQ(net::OK, CreateEntry(key, &entry));
+ entry->Close();
+
+ base::RunLoop().RunUntilIdle();
+ disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting();
+ base::RunLoop().RunUntilIdle();
+
+ EXPECT_TRUE(
+ disk_cache::simple_util::CorruptStream0LengthFromEntry(key, cache_path_));
+ EXPECT_NE(net::OK, OpenEntry(key, &entry));
+}
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_synchronous_entry.h » ('j') | net/disk_cache/simple/simple_synchronous_entry.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698