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

Unified Diff: chrome/utility/safe_browsing/mac/hfs.cc

Issue 2528243002: Fix silent truncations when extracting values from CheckedNumeric (Closed)
Patch Set: compile 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 side-by-side diff with in-line comments
Download patch
Index: chrome/utility/safe_browsing/mac/hfs.cc
diff --git a/chrome/utility/safe_browsing/mac/hfs.cc b/chrome/utility/safe_browsing/mac/hfs.cc
index fd2f75337e4e239a29a30ddde7509723bee0026c..ce1b69c209e5ffd396620320b807c857de37e337 100644
--- a/chrome/utility/safe_browsing/mac/hfs.cc
+++ b/chrome/utility/safe_browsing/mac/hfs.cc
@@ -383,12 +383,12 @@ bool HFSForkReadStream::Read(uint8_t* buffer,
read_current_extent_ = true;
}
- size_t extent_offset = fork_logical_offset_ % extent_size.ValueOrDie();
- size_t bytes_to_copy =
- std::min(std::min(static_cast<size_t>(fork_.logicalSize) -
- fork_logical_offset_,
- extent_size.ValueOrDie() - extent_offset),
- buffer_space_remaining);
+ size_t extent_offset = (fork_logical_offset_ % extent_size).ValueOrDie();
+ size_t bytes_to_copy = std::min(
+ std::min(
+ static_cast<size_t>(fork_.logicalSize) - fork_logical_offset_,
+ static_cast<size_t>((extent_size - extent_offset).ValueOrDie())),
+ buffer_space_remaining);
memcpy(&buffer[buffer_size - buffer_space_remaining],
&current_extent_data_[extent_offset],

Powered by Google App Engine
This is Rietveld 408576698