Commit 8bf2a7b
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 3ed403e commit 8bf2a7b
2 files changed
+19
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
89 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
| |||
137 | 140 | | |
138 | 141 | | |
139 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
140 | 151 | | |
141 | 152 | | |
142 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
95 | 100 | | |
96 | 101 | | |
97 | 102 | | |
| |||
0 commit comments