diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-02 00:52:21 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-02 00:52:21 +0000 |
commit | 2408380ce8f8b90dd577a0403958bb292aec0d68 (patch) | |
tree | 0d4fd40e93b9985832be7dccc9ac5f09584b602b /net/disk_cache/entry_unittest.cc | |
parent | 347867b7b712fb62a5340da298b69f30e3443c49 (diff) | |
download | chromium_src-2408380ce8f8b90dd577a0403958bb292aec0d68.zip chromium_src-2408380ce8f8b90dd577a0403958bb292aec0d68.tar.gz chromium_src-2408380ce8f8b90dd577a0403958bb292aec0d68.tar.bz2 |
Fixing a crash in disk_cache::SparseControl::UpdateRange()
TEST=net_unittests --gtest_filter=DiskCacheEntryTest::PArtialSparseEntry
If we do a partial write with the following criteria, disk_cache::SparseControl
will crash:
1. first_byte and last_byte in the same 1KB block
2. first_byte % 1024 != 0
3. (first_byte >> 10) % 32 == 31
Review URL: http://codereview.chromium.org/176067
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25134 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/entry_unittest.cc')
-rw-r--r-- | net/disk_cache/entry_unittest.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/net/disk_cache/entry_unittest.cc b/net/disk_cache/entry_unittest.cc index 1c81995..f65f593 100644 --- a/net/disk_cache/entry_unittest.cc +++ b/net/disk_cache/entry_unittest.cc @@ -1216,12 +1216,17 @@ void DiskCacheEntryTest::PartialSparseEntry() { // We should be able to deal with IO that is not aligned to the block size // of a sparse entry, at least to write a big range without leaving holes. const int kSize = 4 * 1024; + const int kSmallSize = 128; scoped_refptr<net::IOBuffer> buf1 = new net::IOBuffer(kSize); CacheTestFillBuffer(buf1->data(), kSize, false); - // The first write is just to extend the entry. + // The first write is just to extend the entry. The third write occupies + // a 1KB block partially, it may not be written internally depending on the + // implementation. EXPECT_EQ(kSize, entry->WriteSparseData(20000, buf1, kSize, NULL)); EXPECT_EQ(kSize, entry->WriteSparseData(500, buf1, kSize, NULL)); + EXPECT_EQ(kSmallSize, + entry->WriteSparseData(1080321, buf1, kSmallSize, NULL)); entry->Close(); ASSERT_TRUE(cache_->OpenEntry(key, &entry)); |