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

Side by Side Diff: content/browser/appcache/appcache_internals_ui.cc

Issue 2528243002: Fix silent truncations when extracting values from CheckedNumeric (Closed)
Patch Set: compile cleanup and fix Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/appcache/appcache_internals_ui.h" 5 #include "content/browser/appcache/appcache_internals_ui.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 return; 280 return;
281 if (!appcache_service_) 281 if (!appcache_service_)
282 return; 282 return;
283 ResponseEnquiry response_enquiry = response_enquiries_.front(); 283 ResponseEnquiry response_enquiry = response_enquiries_.front();
284 response_enquiries_.pop_front(); 284 response_enquiries_.pop_front();
285 if (response) { 285 if (response) {
286 scoped_refptr<AppCacheResponseInfo> response_info = response; 286 scoped_refptr<AppCacheResponseInfo> response_info = response;
287 const int64_t kLimit = 100 * 1000; 287 const int64_t kLimit = 100 * 1000;
288 int64_t amount_to_read = 288 int64_t amount_to_read =
289 std::min(kLimit, response_info->response_data_size()); 289 std::min(kLimit, response_info->response_data_size());
290 scoped_refptr<net::IOBuffer> response_data(new net::IOBuffer( 290 scoped_refptr<net::IOBuffer> response_data(
291 base::CheckedNumeric<size_t>(amount_to_read).ValueOrDie())); 291 new net::IOBuffer(base::checked_cast<size_t>(amount_to_read)));
292 std::unique_ptr<AppCacheResponseReader> reader( 292 std::unique_ptr<AppCacheResponseReader> reader(
293 appcache_service_->storage()->CreateResponseReader( 293 appcache_service_->storage()->CreateResponseReader(
294 GURL(response_enquiry.manifest_url), response_enquiry.response_id)); 294 GURL(response_enquiry.manifest_url), response_enquiry.response_id));
295 295
296 reader->ReadData( 296 reader->ReadData(
297 response_data.get(), amount_to_read, 297 response_data.get(), amount_to_read,
298 base::Bind(&Proxy::OnResponseDataReadComplete, this, response_enquiry, 298 base::Bind(&Proxy::OnResponseDataReadComplete, this, response_enquiry,
299 response_info, base::Passed(&reader), response_data)); 299 response_info, base::Passed(&reader), response_data));
300 } else { 300 } else {
301 OnResponseDataReadComplete(response_enquiry, nullptr, nullptr, nullptr, -1); 301 OnResponseDataReadComplete(response_enquiry, nullptr, nullptr, nullptr, -1);
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 const base::FilePath& partition_path) { 503 const base::FilePath& partition_path) {
504 for (const scoped_refptr<Proxy>& proxy : appcache_proxies_) { 504 for (const scoped_refptr<Proxy>& proxy : appcache_proxies_) {
505 if (proxy->partition_path_ == partition_path) 505 if (proxy->partition_path_ == partition_path)
506 return proxy.get(); 506 return proxy.get();
507 } 507 }
508 NOTREACHED(); 508 NOTREACHED();
509 return nullptr; 509 return nullptr;
510 } 510 }
511 511
512 } // namespace content 512 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698