diff options
author | Kristian Monsen <kristianm@google.com> | 2011-11-17 03:22:21 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-11-17 03:22:21 -0800 |
commit | 6c56142cac0a61d46d4a444ffe09cfbf1a66c876 (patch) | |
tree | d0cb945cc7a86deeb1c48449e0cbc6fc7bec1d6b /net/disk_cache/entry_unittest.cc | |
parent | 3a14c9bbe51d89a2d6435c3cec12f59675bde0a8 (diff) | |
parent | 1ab02c36bee95e85558f6815b2836e9ee6a26b19 (diff) | |
download | external_chromium-6c56142cac0a61d46d4a444ffe09cfbf1a66c876.zip external_chromium-6c56142cac0a61d46d4a444ffe09cfbf1a66c876.tar.gz external_chromium-6c56142cac0a61d46d4a444ffe09cfbf1a66c876.tar.bz2 |
am 1ab02c36: Part of fix for bug 5523834, backporting cache fixes
* commit '1ab02c36bee95e85558f6815b2836e9ee6a26b19':
Part of fix for bug 5523834, backporting cache fixes
Diffstat (limited to 'net/disk_cache/entry_unittest.cc')
-rw-r--r-- | net/disk_cache/entry_unittest.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/net/disk_cache/entry_unittest.cc b/net/disk_cache/entry_unittest.cc index 9c6b28a..ce3696c 100644 --- a/net/disk_cache/entry_unittest.cc +++ b/net/disk_cache/entry_unittest.cc @@ -1944,3 +1944,29 @@ TEST_F(DiskCacheEntryTest, CancelSparseIO) { EXPECT_EQ(0, cb5.GetResult(rv)); entry->Close(); } + +// Tests that we perform sanity checks on an entry's key. Note that there are +// other tests that exercise sanity checks by using saved corrupt files. +TEST_F(DiskCacheEntryTest, KeySanityCheck) { + UseCurrentThread(); + InitCache(); + std::string key("the first key"); + disk_cache::Entry* entry; + ASSERT_EQ(net::OK, CreateEntry(key, &entry)); + + disk_cache::EntryImpl* entry_impl = + static_cast<disk_cache::EntryImpl*>(entry); + disk_cache::EntryStore* store = entry_impl->entry()->Data(); + + // We have reserved space for a short key (one block), let's say that the key + // takes more than one block, and remove the NULLs after the actual key. + store->key_len = 800; + memset(store->key + key.size(), 'k', sizeof(store->key) - key.size()); + entry_impl->entry()->set_modified(); + entry->Close(); + + // We have a corrupt entry. Now reload it. We should NOT read beyond the + // allocated buffer here. + ASSERT_NE(net::OK, OpenEntry(key, &entry)); + DisableIntegrityCheck(); +} |