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

Side by Side Diff: net/disk_cache/entry_unittest.cc

Issue 2176183008: Simple Cache: validate lengths before allocations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: 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 4247 matching lines...) Expand 10 before | Expand all | Expand 10 after
4258 entry->Close(); 4258 entry->Close();
4259 4259
4260 base::RunLoop().RunUntilIdle(); 4260 base::RunLoop().RunUntilIdle();
4261 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); 4261 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting();
4262 base::RunLoop().RunUntilIdle(); 4262 base::RunLoop().RunUntilIdle();
4263 4263
4264 EXPECT_TRUE( 4264 EXPECT_TRUE(
4265 disk_cache::simple_util::CorruptKeySHA256FromEntry(key, cache_path_)); 4265 disk_cache::simple_util::CorruptKeySHA256FromEntry(key, cache_path_));
4266 EXPECT_NE(net::OK, OpenEntry(key, &entry)); 4266 EXPECT_NE(net::OK, OpenEntry(key, &entry));
4267 } 4267 }
4268
4269 TEST_F(DiskCacheEntryTest, SimpleCacheReadCorruptLength) {
4270 SetCacheType(net::APP_CACHE);
4271 SetSimpleCacheMode();
4272 InitCache();
4273 disk_cache::Entry* entry;
4274 std::string key("a key");
4275 ASSERT_EQ(net::OK, CreateEntry(key, &entry));
4276 entry->Close();
4277
4278 base::RunLoop().RunUntilIdle();
4279 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting();
4280 base::RunLoop().RunUntilIdle();
4281
4282 EXPECT_TRUE(
4283 disk_cache::simple_util::CorruptStream0LengthFromEntry(key, cache_path_));
4284 EXPECT_NE(net::OK, OpenEntry(key, &entry));
4285 }
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