memorysafety / rav1d

An AV1 decoder in Rust.
BSD 2-Clause "Simplified" License
321 stars 22 forks source link

`fn AlignedVec::resize`: Validate safety requirements, specifically overflow #1357

Closed HeroicKatora closed 1 week ago

HeroicKatora commented 3 weeks ago

This is a necessary check for soundness, as demonstrated by the test which can SIGSEGV without the check. Before the check, an overflow in the underlying buffer calculation can create incoherent state where the vector believes in an impossibly large buffer of the item type which is not actually backed by a correctly sized buffer of chunks.