This repository was archived by the owner on Jul 11, 2026. It is now read-only.
Commit c03fb74
feat(GREEN): ewf input hardening — overflow-safe section chain + chunk size cap
Fixes three classes of bugs that allow crafted EWF files to panic the parser:
- reader.rs section chain loop: replace `desc_offset + SECTION_DESCRIPTOR_SIZE`
with `checked_add`; overflow (e.g. next=u64::MAX) breaks the chain cleanly
instead of panicking.
- reader.rs sectors_data_end: replace `d.offset + d.section_size` with
`saturating_add`; a crafted section_size=u64::MAX no longer overflows.
- reader.rs volume handler: add MAX_CHUNK_SIZE (128 MB) check before accepting
chunk_size from the volume section → Err(InvalidChunkSize) instead of deferring
to a 128 MB+ allocation in read_chunk(); add MAX_CHUNK_COUNT (4M) check before
chunks.reserve() → Err(Parse) instead of potential OOM.
131 existing tests pass with 0 regressions.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 65780d1 commit c03fb74
1 file changed
Lines changed: 26 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
97 | 103 | | |
98 | 104 | | |
99 | 105 | | |
| |||
240 | 246 | | |
241 | 247 | | |
242 | 248 | | |
243 | | - | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
244 | 255 | | |
245 | 256 | | |
246 | 257 | | |
| |||
262 | 273 | | |
263 | 274 | | |
264 | 275 | | |
265 | | - | |
| 276 | + | |
| 277 | + | |
266 | 278 | | |
267 | 279 | | |
268 | 280 | | |
269 | | - | |
| 281 | + | |
270 | 282 | | |
271 | 283 | | |
272 | 284 | | |
| |||
277 | 289 | | |
278 | 290 | | |
279 | 291 | | |
280 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
281 | 303 | | |
282 | 304 | | |
283 | 305 | | |
| |||
0 commit comments