formats: reject truncated SWF movie headers in gfx::Movie::parse #45
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/45"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from edsuuu/VI-BR-PORT. Originally posted by ahmetbagci8 on 2026-11-29T20:43:17Z.
Problem
In crates/victory-formats/src/gfx.rs, Movie::parse computes irst = 8 + (5 + 4 * field_bits).div_ceil(8) + 4 and passes irst..bytes.len() to ags() without checking irst <= bytes.len(). When a header is truncated (irst > bytes.len()), ags() exits its while at < range.end loop immediately and returns Some(vec![]), so Movie::parse succeeds with self.first > self.bytes.len() and subsequent
eplace_shapes fails on self.bytes.get(..self.first)?.
Fix
Return None from Movie::parse when irst > bytes.len(), and add unit test runcated_movie_header_is_refused.
Verification