Commit 55e646a
Github Executorch
Fix integer overflow in PlatformMemoryAllocator::allocate() (TOB-EXECUTORCH-26)
Add overflow checking before computing the total allocation size
(sizeof(AllocationNode) + size + alignment) in PlatformMemoryAllocator::allocate().
Previously, when this sum exceeded SIZE_MAX, it would wrap around to a small
value, causing pal_allocate to allocate an undersized buffer. This could lead to
subsequent out-of-bounds writes. The fix validates each addition step against
SIZE_MAX and returns nullptr on overflow.
This PR was authored with the assistance of Claude.1 parent 3d2c853 commit 55e646a
1 file changed
+15
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
49 | | - | |
50 | | - | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
51 | 64 | | |
52 | 65 | | |
53 | 66 | | |
| |||
0 commit comments