game: check record bounds and offset arithmetic in sgd5 #1153
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1153"
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 Marvisak/VIctory. Originally posted by DaniiL35 on 2026-11-24T16:16:21Z.
Resolves #905
Problem
In
crates/victory-game/src/sgd5.rs:record()performed unchecked addition:let at = self.names_offset as usize + record.name_offset as usize;and directly sliced&self.data[at..]. If an archive contains corrupt or boundaryname_offsetvalues, this overflows or panics on slice index.name_before()used unchecked subtractionat - 1and unsliced indexingself.data[i].records()could panic ifrecords_offsetwas withindata.len()but had fewer thanrecord_count * size_of::<Record>()bytes available.Fix
records()withchecked_mulandchecked_addagainstdata.len().checked_addinrecord()and bounds-checked slice slicing (.get(at..)).checked_subinname_before()and safe indexing.rejects_boundary_and_malformed_recordsverifying bounds checking and NUL-terminator searching on truncated / corrupted archive headers.All fixtures are synthetic; zero game data (Rule #1 compliant). Formatted with Rust 2024 edition.
Pull request closed