diff options
author | nick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-13 21:25:58 +0000 |
---|---|---|
committer | nick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-13 21:25:58 +0000 |
commit | ed16b6e7a6cde1f3e0e17956a6f7d7a0d6d6a77c (patch) | |
tree | b363ead4f824c5dc0b4f54b4bb51b6e7305f8f6c /net | |
parent | c05a26cc654acceb8062a759adecedeceeeb89b3 (diff) | |
download | chromium_src-ed16b6e7a6cde1f3e0e17956a6f7d7a0d6d6a77c.zip chromium_src-ed16b6e7a6cde1f3e0e17956a6f7d7a0d6d6a77c.tar.gz chromium_src-ed16b6e7a6cde1f3e0e17956a6f7d7a0d6d6a77c.tar.bz2 |
Revert 81472 - Disk Cache: Perform extra validations to data comming fromdisk to detect obvious corruption going undetected.BUG=77841TEST=net_unittestsReview URL: http://codereview.chromium.org/6821064
TBR=rvargas@google.com
Review URL: http://codereview.chromium.org/6837035
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81485 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/disk_cache/addr.cc | 16 | ||||
-rw-r--r-- | net/disk_cache/addr.h | 5 | ||||
-rw-r--r-- | net/disk_cache/addr_unittest.cc | 22 | ||||
-rw-r--r-- | net/disk_cache/entry_impl.cc | 46 | ||||
-rw-r--r-- | net/disk_cache/rankings.cc | 8 |
5 files changed, 8 insertions, 89 deletions
diff --git a/net/disk_cache/addr.cc b/net/disk_cache/addr.cc index c4b95ef..aa84c01 100644 --- a/net/disk_cache/addr.cc +++ b/net/disk_cache/addr.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -26,18 +26,4 @@ bool Addr::SetFileNumber(int file_number) { return true; } -bool Addr::SanityCheck() const { - if (!is_initialized()) - return !value_; - - if (((value_ & kFileTypeMask) >> kFileTypeOffset) > 4) - return false; - - if (is_separate_file()) - return true; - - const uint32 kReservedBitsMask = 0x0c000000; - return !(value_ & kReservedBitsMask); -} - } // namespace disk_cache diff --git a/net/disk_cache/addr.h b/net/disk_cache/addr.h index d754ec5..c10dcc3 100644 --- a/net/disk_cache/addr.h +++ b/net/disk_cache/addr.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -119,9 +119,6 @@ class Addr { return EXTERNAL; } - // Returns true if this address looks like a valid one. - bool SanityCheck() const; - private: static const uint32 kInitializedMask = 0x80000000; static const uint32 kFileTypeMask = 0x70000000; diff --git a/net/disk_cache/addr_unittest.cc b/net/disk_cache/addr_unittest.cc index 09088c4..551310e 100644 --- a/net/disk_cache/addr_unittest.cc +++ b/net/disk_cache/addr_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -34,24 +34,4 @@ TEST_F(DiskCacheTest, CacheAddr_InvalidValues) { EXPECT_EQ(4096, addr3.BlockSize()); } -TEST_F(DiskCacheTest, CacheAddr_SanityCheck) { - // First a few valid values. - EXPECT_TRUE(Addr(0).SanityCheck()); - EXPECT_TRUE(Addr(0x80001000).SanityCheck()); - EXPECT_TRUE(Addr(0xC3FFFFFF).SanityCheck()); - EXPECT_TRUE(Addr(0xC0FFFFFF).SanityCheck()); - - // Not initialized. - EXPECT_FALSE(Addr(0x20).SanityCheck()); - EXPECT_FALSE(Addr(0x10001000).SanityCheck()); - - // Invalid file type. - EXPECT_FALSE(Addr(0xD0001000).SanityCheck()); - EXPECT_FALSE(Addr(0xF0000000).SanityCheck()); - - // Reserved bits. - EXPECT_FALSE(Addr(0x14000000).SanityCheck()); - EXPECT_FALSE(Addr(0x18000000).SanityCheck()); -} - } // namespace disk_cache diff --git a/net/disk_cache/entry_impl.cc b/net/disk_cache/entry_impl.cc index 73c67df..2db4988 100644 --- a/net/disk_cache/entry_impl.cc +++ b/net/disk_cache/entry_impl.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,7 +12,6 @@ #include "net/disk_cache/backend_impl.h" #include "net/disk_cache/bitmap.h" #include "net/disk_cache/cache_util.h" -#include "net/disk_cache/hash.h" #include "net/disk_cache/histogram_macros.h" #include "net/disk_cache/net_log_parameters.h" #include "net/disk_cache/sparse_control.h" @@ -560,56 +559,19 @@ void EntryImpl::SetPointerForInvalidEntry(int32 new_id) { } bool EntryImpl::SanityCheck() { - EntryStore* stored = entry_.Data(); - if (!stored->rankings_node || stored->key_len <= 0) + if (!entry_.Data()->rankings_node || !entry_.Data()->key_len) return false; - if (stored->reuse_count < 0 || stored->refetch_count < 0) - return false; - - Addr rankings_addr(stored->rankings_node); + Addr rankings_addr(entry_.Data()->rankings_node); if (!rankings_addr.is_initialized() || rankings_addr.is_separate_file() || rankings_addr.file_type() != RANKINGS) return false; - Addr next_addr(stored->next); + Addr next_addr(entry_.Data()->next); if (next_addr.is_initialized() && (next_addr.is_separate_file() || next_addr.file_type() != BLOCK_256)) return false; - if (!rankings_addr.SanityCheck() || !next_addr.SanityCheck()) - return false; - - if (stored->state > ENTRY_DOOMED || stored->state < ENTRY_NORMAL) - return false; - - Addr key_addr(stored->long_key); - if (stored->key_len <= kMaxInternalKeyLength && key_addr.is_initialized()) - return false; - - if (!key_addr.SanityCheck()) - return false; - - if (stored->hash != Hash(GetKey())) - return false; - - for (int i = 0; i < kNumStreams; i++) { - Addr data_addr(stored->data_addr[i]); - int data_size = stored->data_size[i]; - if (data_size < 0) - return false; - if (!data_size && data_addr.is_initialized()) - return false; - if (!data_addr.SanityCheck()) - return false; - if (!data_size) - continue; - if (data_size <= kMaxBlockSize && data_addr.is_separate_file()) - return false; - if (data_size > kMaxBlockSize && data_addr.is_block_file()) - return false; - } - return true; } diff --git a/net/disk_cache/rankings.cc b/net/disk_cache/rankings.cc index e8bf50d..3644932 100644 --- a/net/disk_cache/rankings.cc +++ b/net/disk_cache/rankings.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -508,12 +508,6 @@ bool Rankings::SanityCheck(CacheRankingsBlock* node, bool from_list) { if ((node->address().value() == data->next) && !IsTail(data->next, &list)) return false; - Addr next_addr(data->next); - Addr prev_addr(data->prev); - if (!next_addr.SanityCheck() || next_addr.file_type() != RANKINGS || - !prev_addr.SanityCheck() || prev_addr.file_type() != RANKINGS) - return false; - return true; } |