commit | 28b51cf40ee4e5abb3880cf771308ed95a8e325c | [log] [tgz] |
---|---|---|
author | Peter Kasting <[email protected]> | Tue Jun 28 15:02:43 2022 |
committer | Chromium LUCI CQ <[email protected]> | Tue Jun 28 15:02:43 2022 |
tree | c4bffaf5b5ab338a375e44e6b4b77768136e11e6 | |
parent | c8f60d0ffd7547572396d85723311d73b346fa25 [diff] [blame] |
Reland: Prevent unsafe narrowing: base/ This relands https://chromium-review.googlesource.com/c/chromium/src/+/3717404 . Bug: 1292951 Change-Id: I79a1d884d297903886cf3d8819f8962ba250ccb9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3727447 Commit-Queue: Peter Kasting <[email protected]> Auto-Submit: Peter Kasting <[email protected]> Reviewed-by: danakj <[email protected]> Owners-Override: danakj <[email protected]> Cr-Commit-Position: refs/heads/main@{#1018684}
diff --git a/ipc/ipc_message_protobuf_utils.h b/ipc/ipc_message_protobuf_utils.h index f06a176..ad3638cd 100644 --- a/ipc/ipc_message_protobuf_utils.h +++ b/ipc/ipc_message_protobuf_utils.h
@@ -25,15 +25,14 @@ static bool Read(const base::Pickle* m, base::PickleIterator* iter, param_type* r) { - int size; - // ReadLength() checks for < 0 itself. + size_t size; if (!iter->ReadLength(&size)) return false; // Avoid integer overflow / assertion failure in Reserve() function. - if (INT_MAX / sizeof(StorageType) <= static_cast<size_t>(size)) + if (size > INT_MAX / sizeof(StorageType)) return false; r->Reserve(size); - for (int i = 0; i < size; i++) { + for (size_t i = 0; i < size; i++) { if (!ReadParam(m, iter, r->Add())) return false; }