game: check record bounds and offset arithmetic in sgd5 #1153
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!1153
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1153/head"
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?
@DaniiL35 on GitHub · 2026-11-24 16:16 UTC · original
fix/sgd5-checked-record-bounds→main· +53 −9 · 1 files · 1 commits · closed without mergingResolves #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