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

Side by Side 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: remediate Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_synchronous_entry.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <utility> 5 #include <utility>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 4256 matching lines...) Expand 10 before | Expand all | Expand 10 after
4267 entry->Close(); 4267 entry->Close();
4268 4268
4269 base::RunLoop().RunUntilIdle(); 4269 base::RunLoop().RunUntilIdle();
4270 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); 4270 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting();
4271 base::RunLoop().RunUntilIdle(); 4271 base::RunLoop().RunUntilIdle();
4272 4272
4273 EXPECT_TRUE( 4273 EXPECT_TRUE(
4274 disk_cache::simple_util::CorruptKeySHA256FromEntry(key, cache_path_)); 4274 disk_cache::simple_util::CorruptKeySHA256FromEntry(key, cache_path_));
4275 EXPECT_NE(net::OK, OpenEntry(key, &entry)); 4275 EXPECT_NE(net::OK, OpenEntry(key, &entry));
4276 } 4276 }
4277
4278 TEST_F(DiskCacheEntryTest, SimpleCacheReadCorruptLength) {
4279 SetCacheType(net::APP_CACHE);
4280 SetSimpleCacheMode();
4281 InitCache();
4282 disk_cache::Entry* entry;
4283 std::string key("a key");
4284 ASSERT_EQ(net::OK, CreateEntry(key, &entry));
4285 entry->Close();
4286
4287 base::RunLoop().RunUntilIdle();
4288 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting();
4289 base::RunLoop().RunUntilIdle();
4290
4291 EXPECT_TRUE(
4292 disk_cache::simple_util::CorruptStream0LengthFromEntry(key, cache_path_));
4293 EXPECT_NE(net::OK, OpenEntry(key, &entry));
4294 }
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_synchronous_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698