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

Side by Side Diff: components/nacl/browser/pnacl_host.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/nacl/browser/pnacl_host.h" 5 #include "components/nacl/browser/pnacl_host.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 // TODO(eroman): Maximum size should be changed to size_t once that is 411 // TODO(eroman): Maximum size should be changed to size_t once that is
412 // what IOBuffer requires. crbug.com/488553. Also I don't think the 412 // what IOBuffer requires. crbug.com/488553. Also I don't think the
413 // max size should be inclusive here... 413 // max size should be inclusive here...
414 int64_t file_size = file->GetLength(); 414 int64_t file_size = file->GetLength();
415 if (file_size < 0 || file_size > std::numeric_limits<int>::max()) { 415 if (file_size < 0 || file_size > std::numeric_limits<int>::max()) {
416 PLOG(ERROR) << "Get file length failed " << file_size; 416 PLOG(ERROR) << "Get file length failed " << file_size;
417 return buffer; 417 return buffer;
418 } 418 }
419 419
420 buffer = new net::DrainableIOBuffer( 420 buffer = new net::DrainableIOBuffer(
421 new net::IOBuffer(base::CheckedNumeric<size_t>(file_size).ValueOrDie()), 421 new net::IOBuffer(base::checked_cast<size_t>(file_size)),
422 base::CheckedNumeric<size_t>(file_size).ValueOrDie()); 422 base::checked_cast<size_t>(file_size));
423 if (file->Read(0, buffer->data(), buffer->size()) != file_size) { 423 if (file->Read(0, buffer->data(), buffer->size()) != file_size) {
424 PLOG(ERROR) << "CopyFileToBuffer file read failed"; 424 PLOG(ERROR) << "CopyFileToBuffer file read failed";
425 buffer = nullptr; 425 buffer = nullptr;
426 } 426 }
427 return buffer; 427 return buffer;
428 } 428 }
429 429
430 // Called by the renderer in the miss path to report a finished translation 430 // Called by the renderer in the miss path to report a finished translation
431 void PnaclHost::TranslationFinished(int render_process_id, 431 void PnaclHost::TranslationFinished(int render_process_id,
432 int pp_instance, 432 int pp_instance,
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 DCHECK(pending_backend_operations_ >= 0); 659 DCHECK(pending_backend_operations_ >= 0);
660 if (pending_translations_.empty() && 660 if (pending_translations_.empty() &&
661 pending_backend_operations_ <= 0 && 661 pending_backend_operations_ <= 0 &&
662 cache_state_ == CacheReady) { 662 cache_state_ == CacheReady) {
663 cache_state_ = CacheUninitialized; 663 cache_state_ = CacheUninitialized;
664 disk_cache_.reset(); 664 disk_cache_.reset();
665 } 665 }
666 } 666 }
667 667
668 } // namespace pnacl 668 } // namespace pnacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698