Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1515)

Unified Diff: net/http/http_cache_transaction.cc

Issue 14533007: Avoid crashing the browser on truncated reads from the cache backend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache_transaction.cc
diff --git a/net/http/http_cache_transaction.cc b/net/http/http_cache_transaction.cc
index 07fa4dbacc4dbb68763c70cfde3c639a809e6677..090e8f25783348beaa5675555556fac47248ec27 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.HeaderTruncated", false);
+ } else {
+ UMA_HISTOGRAM_BOOLEAN("HttpCache.HeaderTruncated", 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.MetadataTruncated", false);
+ } else {
+ UMA_HISTOGRAM_BOOLEAN("HttpCache.MetadataTruncated", 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();
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | tools/metrics/histograms/histograms.xml » ('J')

Powered by Google App Engine
This is Rietveld 408576698