Commit 1d11c95
committed
fix(egfx): cap Avc420BitmapStream pre-allocation against remaining bytes
Avc420BitmapStream::decode reads a u32 num_regions and called
Vec::with_capacity(num_regions as usize) twice without bounding the
value. A fuzzer-controlled num_regions near u32::MAX caused the
allocator to attempt several gigabytes per call, which ASan trapped
as out-of-memory in the new pdu_decode egfx coverage.
Caps the with_capacity argument at src.len() / per-region size, where
per-region is the minimum decode footprint (InclusiveRectangle plus
QuantQuality). The actual read loop is unchanged and still returns
NotEnoughBytes via the inner Decode impls if num_regions does not
match the actual payload, so the only behavioural change is bounded
pre-allocation. Surfaced by the egfx fuzz coverage added earlier on
this branch.1 parent ad1401f commit 1d11c95
1 file changed
Lines changed: 9 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
121 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
122 | 129 | | |
123 | 130 | | |
124 | 131 | | |
| |||
0 commit comments