Commit 8b929f4
rhoopr
saiz/saio/hvcc: bound Vec::with_capacity on attacker-controlled counts
Three more `Vec::with_capacity` sites pass a count read straight from
input as the capacity argument, with no upper bound:
- `saiz` `sample_count` (`Vec<u8>`, `u32`): worst case ~4 GiB upfront.
- `saio` `entry_count` (`Vec<u64>`, `u32`): worst case ~34 GiB upfront
for v1 (8 bytes/entry).
- `hvcc` `num_nalus` (`Vec<Vec<u8>>`, `u16`): worst case ~1.5 MiB
upfront (24 bytes per `Vec<u8>` slot).
Same defensive idiom as #157: pre-flight reject counts that cannot
possibly fit in the remaining buffer (`count > buf.remaining() / N`,
where N is the per-element minimum), then cap the upfront reservation.
- saiz/saio: cap at 4096 to match `trun.rs` — covers typical CMAF
segments (hundreds to low thousands of samples) without reallocating.
- hvcc: cap at 64 — real HEVC arrays hold a handful of VPS/SPS/PPS/SEI
entries, so 4096 would be well past anything realistic.
Adds regression tests pinned to `Error::OverDecode` (the wrapper that
`Atom::decode_maybe` produces from `Error::OutOfBounds`).
Closes #156.1 parent 3366b08 commit 8b929f4
2 files changed
Lines changed: 77 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
55 | 60 | | |
56 | 61 | | |
57 | 62 | | |
| |||
115 | 120 | | |
116 | 121 | | |
117 | 122 | | |
118 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
119 | 130 | | |
120 | 131 | | |
121 | 132 | | |
| |||
427 | 438 | | |
428 | 439 | | |
429 | 440 | | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
430 | 467 | | |
431 | 468 | | |
432 | 469 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
76 | 83 | | |
77 | 84 | | |
78 | 85 | | |
| |||
420 | 427 | | |
421 | 428 | | |
422 | 429 | | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
423 | 460 | | |
424 | 461 | | |
425 | 462 | | |
| |||
0 commit comments