Commit e260706
committed
Fix integer overflow in tensor dimensions and PPM parser
- util/basics.h: Add overflow check in Extents2D::Area() before
computing rows*cols. Malicious model files with large dimension
values could cause a silent size_t overflow, leading to undersized
allocations and subsequent heap buffer overflows.
- paligemma/image.cc: Add overflow check for width*height*3 in
ReadPPM(). A crafted PPM file with large dimensions could overflow
the data_size computation, resulting in an undersized buffer and
out-of-bounds writes.
- paligemma/image.cc: Add overflow detection in ParseUnsigned() to
reject values that would overflow size_t during decimal parsing.1 parent 221d8df commit e260706
2 files changed
Lines changed: 19 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
87 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
88 | 91 | | |
89 | 92 | | |
90 | 93 | | |
| |||
136 | 139 | | |
137 | 140 | | |
138 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
139 | 150 | | |
140 | 151 | | |
141 | 152 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
101 | 106 | | |
102 | 107 | | |
103 | 108 | | |
| |||
0 commit comments