summaryrefslogtreecommitdiffstats
path: root/net/disk_cache
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-04 23:52:08 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-04 23:52:08 +0000
commit41434cbf03d6e16d7d0cd59a7155f54b75ed1798 (patch)
tree25b043fb9d4c614d51337a243e6e63204aafecf5 /net/disk_cache
parent674741939c4b887877859bced1f21e17d64c4b85 (diff)
downloadchromium_src-41434cbf03d6e16d7d0cd59a7155f54b75ed1798.zip
chromium_src-41434cbf03d6e16d7d0cd59a7155f54b75ed1798.tar.gz
chromium_src-41434cbf03d6e16d7d0cd59a7155f54b75ed1798.tar.bz2
Disk cache: Add a check to make sure that the index table mask is not bigger than the table itself.
BUG=7217 Review URL: http://codereview.chromium.org/20054 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9190 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache')
-rw-r--r--net/disk_cache/backend_impl.cc13
-rw-r--r--net/disk_cache/errors.h3
2 files changed, 14 insertions, 2 deletions
diff --git a/net/disk_cache/backend_impl.cc b/net/disk_cache/backend_impl.cc
index 4698754..5fbb390 100644
--- a/net/disk_cache/backend_impl.cc
+++ b/net/disk_cache/backend_impl.cc
@@ -846,6 +846,9 @@ void BackendImpl::PrepareForRestart() {
rankings_.Reset();
init_ = false;
restarted_ = true;
+
+ // TODO(rvargas): remove this line at the end of this experiment.
+ max_size_ = 0;
}
int BackendImpl::NewEntry(Addr address, EntryImpl** entry, bool* dirty) {
@@ -1093,7 +1096,7 @@ bool BackendImpl::CheckIndex() {
}
AdjustMaxCacheSize(data_->header.table_len);
-
+
// We need to avoid integer overflows.
DCHECK(max_size_ < kint32max - kint32max / 10);
if (data_->header.num_bytes < 0 ||
@@ -1110,6 +1113,14 @@ bool BackendImpl::CheckIndex() {
if (!mask_)
mask_ = data_->header.table_len - 1;
+ // TODO(rvargas): remove this. For some reason, we are receiving crashes with
+ // mask_ being bigger than the actual table length. (bug 7217).
+ if (mask_ > 0xffff) {
+ LOG(ERROR) << "Invalid cache mask";
+ ReportError(ERR_INVALID_MASK);
+ return false;
+ }
+
return true;
}
diff --git a/net/disk_cache/errors.h b/net/disk_cache/errors.h
index eea087a..991086f 100644
--- a/net/disk_cache/errors.h
+++ b/net/disk_cache/errors.h
@@ -21,7 +21,8 @@ enum {
ERR_NUM_ENTRIES_MISMATCH = -9,
ERR_READ_FAILURE = -10,
ERR_PREVIOUS_CRASH = -11,
- ERR_STORAGE_ERROR = -12
+ ERR_STORAGE_ERROR = -12,
+ ERR_INVALID_MASK = -13
};
} // namespace disk_cache