gpu: bounds-check pipeline stream subobjects before reading #37
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/37"
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-29T12:39:34Z.
Problem
In crates/victory-gpu/src/pipeline.rs, create_stream loops while at + 8 <= desc.size, reads the subobject kind and looks up its size, and then immediately reads a Bytecode at desc.stream.add(at + 8) and passes desc.stream.add(at) to graphics.read(kind, ...) (up to 336 bytes) without checking that size <= desc.size - at. A truncated subobject at the end of a stream causes out-of-bounds reads / UB.
Fix
Verify size <= desc.size - at (and use desc.size.saturating_sub(at) >= 8 in the loop condition plus
ead_unaligned() for Bytecode) before reading any subobject payload, breaking with a warning if truncated. Added unit test runcated_stream_subobject_is_ignored_without_reading_past_end.
Verification
Imported from edsuuu/VI-BR-PORT. Originally posted by edsuuu on 2026-11-29T13:19:43Z.
Review: APPROVED
Thanks, clean and well tested. It passed our full local CI together with the other fixes of this batch. Merged into
dev, where everything is tested in the game first; it reachesmainwith the next release.