Game: check record bounds and offset arithmetic in SGD5 parsing #1436
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!1436
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1436/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?
@fuzeofficlal on GitHub · 2026-11-24 17:58 UTC · original
fuzeofficlal:fix/game-sgd5-bounds-905→main· +70 −9 · 1 files · 1 commits · closed without mergingFixes #905.
Summary
sgd5::recordandsgd5::name_beforewithchecked_add,checked_sub, and.get(...)bounds checks so truncated or malformedSGD5streams returnNoneinstead of panicking.Verification
rejects_boundary_and_malformed_recordscovering short prefixes (at < 6), truncated headers/payloads, mismatched lengths,u32::MAX/usize::MAXoffsets, and malformed name prefixes.cargo test --workspace,cargo clippy --workspace --all-targets --all-features, andcargo xtask policy: passed.@Marvisak on GitHub · 2026-11-25 01:28 UTC · original · edited 2026-11-25 06:30 UTC
Automated triage for the maintainers.
Proposed close: guards for cases that cannot occur. In
crates/victory-game/src/sgd5.rsonmain,record()has a single caller,records(), which passesatfrommemmem::find_iter(file, &MARKER). Soat + 4 <= file.len(), andat + 4,at + 8,at + 12andat + n(withnfrom au32) cannot overflowusize. The existingat.checked_sub(6)?already returns beforefile[nul]andfile[at - 5]could go out of range.file.get(at + 12..at + n)already rejects a truncated payload.name_beforeis only called withnul < at <= file.len(), so its indices are in range too. Everyrecords(..)assertion in the new test also holds onmain. The calls that differ (record(&MARKER, usize::MAX),name_before(&[0], 5)) use arguments no caller can pass. The same change was closed before as #1153.A malformed input that makes
mainpanic throughrecords()would change this verdict.CI: passing (
check).This pull request will be closed in 48 hours unless the author pushes a change or a maintainer removes the
triage: proposed closelabel.Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-25 10:16 UTC · original
Agreed with the triage analysis —
records()boundsatviamemmem::find_iterand.get(...)on 64-bitusize, so the internal helper edge cases cannot be reached onmain. Closing to keep the review queue focused.Pull request closed