diff options
author | pasko@google.com <pasko@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-29 22:31:33 +0000 |
---|---|---|
committer | pasko@google.com <pasko@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-04-29 22:31:33 +0000 |
commit | 610fb6f30d01c45fd0813a6d3cf46dadad6d32ec (patch) | |
tree | 74235f8a121e3565a590eacc59b2fca869565792 /net | |
parent | 6badcc5917e7c9a000f0e6f17cc7601b8fe5c114 (diff) | |
download | chromium_src-610fb6f30d01c45fd0813a6d3cf46dadad6d32ec.zip chromium_src-610fb6f30d01c45fd0813a6d3cf46dadad6d32ec.tar.gz chromium_src-610fb6f30d01c45fd0813a6d3cf46dadad6d32ec.tar.bz2 |
Avoid crashing the browser on truncated reads from the cache backend
BUG=236384
Review URL: https://chromiumcodereview.appspot.com/14533007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197164 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/http/http_cache_transaction.cc | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc index 07fa4db..57a309e 100644 --- a/net/http/http_cache_transaction.cc +++ b/net/http/http_cache_transaction.cc @@ -1385,6 +1385,17 @@ int HttpCache::Transaction::DoCacheReadResponse() { next_state_ = STATE_CACHE_READ_RESPONSE_COMPLETE; io_buf_len_ = entry_->disk_entry->GetDataSize(kResponseInfoIndex); + if (io_buf_len_ > 0) { + UMA_HISTOGRAM_BOOLEAN("HttpCache.TruncatedHeader", false); + } else { + UMA_HISTOGRAM_BOOLEAN("HttpCache.TruncatedHeader", true); + DLOG(WARNING) << "Truncated cache entry header encountered"; + mode_ = NONE; + if (partial_.get()) + partial_->RestoreHeaders(&custom_request_->extra_headers); + next_state_ = STATE_SEND_REQUEST; + return OK; + } read_buf_ = new IOBuffer(io_buf_len_); net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO); @@ -1482,8 +1493,19 @@ int HttpCache::Transaction::DoCacheReadMetadata() { DCHECK(!response_.metadata); next_state_ = STATE_CACHE_READ_METADATA_COMPLETE; - response_.metadata = - new IOBufferWithSize(entry_->disk_entry->GetDataSize(kMetadataIndex)); + int32 data_size = entry_->disk_entry->GetDataSize(kMetadataIndex); + if (data_size > 0) { + UMA_HISTOGRAM_BOOLEAN("HttpCache.TruncatedMetadata", false); + } else { + UMA_HISTOGRAM_BOOLEAN("HttpCache.TruncatedMetadata", true); + DLOG(WARNING) << "Truncated cache entry metadata encountered"; + mode_ = NONE; + if (partial_.get()) + partial_->RestoreHeaders(&custom_request_->extra_headers); + next_state_ = STATE_SEND_REQUEST; + return OK; + } + response_.metadata = new IOBufferWithSize(data_size); net_log_.BeginEvent(NetLog::TYPE_HTTP_CACHE_READ_INFO); ReportCacheActionStart(); |