Skip to content

Commit 42e3222

Browse files
authored
Re-land cve security fix (#16103)
Summary: Was reverted by D78689027 Differential Revision: D88502561
1 parent 4014597 commit 42e3222

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

runtime/core/hierarchical_allocator.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ class HierarchicalAllocator final {
5757
uint32_t memory_id,
5858
size_t offset_bytes,
5959
size_t size_bytes) {
60+
// Check for integer overflow in offset_bytes + size_bytes.
61+
ET_CHECK_OR_RETURN_ERROR(
62+
size_bytes <= SIZE_MAX - offset_bytes,
63+
InvalidArgument,
64+
"Integer overflow in offset_bytes (%" ET_PRIsize_t
65+
") + size_bytes (%" ET_PRIsize_t ")",
66+
offset_bytes,
67+
size_bytes);
6068
ET_CHECK_OR_RETURN_ERROR(
6169
memory_id < buffers_.size(),
6270
InvalidArgument,

0 commit comments

Comments
 (0)