Commit e59c0bd
Fix integer overflow in program.cpp bounds checks (#18662)
17: In get_constant_buffer_data(), the bounds check `offset + nbytes <=
size` can overflow when offset and nbytes are large. Replace with the
overflow-safe pattern
`offset <= size && nbytes <= size - offset`.
24: In Program::load(), the computation `segment_base_offset +
segment_data_size` for the expected file size can overflow. Add an
explicit overflow check before the addition to ensure the sum does not
exceed SIZE_MAX.
This PR was authored with the assistance of Claude.
Co-authored-by: Github Executorch <github_executorch@arm.com>1 parent 8919ef8 commit e59c0bd
1 file changed
+7
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
95 | 101 | | |
96 | 102 | | |
97 | 103 | | |
| |||
429 | 435 | | |
430 | 436 | | |
431 | 437 | | |
432 | | - | |
| 438 | + | |
433 | 439 | | |
434 | 440 | | |
435 | 441 | | |
| |||
0 commit comments