Game: use checked length arithmetic and avoid discarded Vec allocations in sgd5 #2577
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!2577
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2577"
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?
@reeledMarek on GitHub · 2026-11-25 16:08 UTC · original
reeledMarek:fix/game-sgd5-checked-math-and-allocs→main· +46 −18 · 1 files · 1 commits · closed without mergingSummary
Fixes unchecked arithmetic and wasted allocations in
victory-game/src/sgd5.rs:checked_mul/checked_addso malformed SGD5 payloads return a clean parse error instead of overflowing or panicking.Vecallocations during SGD5 entry decoding, parsing directly from borrowed slices (as_chunks::<4>()).Testing
cargo test -p victory-game --locked(16/16 passed)cargo clippy -p victory-game --all-targets --target x86_64-pc-windows-msvc --locked -- -D warnings(clean)cargo test -p xtask --locked(6/6 passed)@Marvisak on GitHub · 2026-11-25 22:17 UTC · original
Automated triage for the maintainers.
Proposed close: guards for cases that cannot happen. VIctory builds only for
x86_64-pc-windows-msvc(rust-toolchain.toml). Insgd5::recordandsgd5::effect, every term added is either au32widened to a 64-bitusizeor the length of a slice already read from the file.at + 12,at + nand theloadedsum cannot overflow there. Onmainan oversized length already makesfile.get(..)/Cursor::bytesreturnNone. The new testrecord_rejects_overflowing_lengthpasses onmainunchanged for that reason, so it does not show a bug. What remains isskip_itemsin place of two discarded smallVecs in an offline parser, which does not justify the change by itself.This PR will be closed in 48 hours unless the author pushes a change (for example a case that panics or misparses on
main) or a maintainer removes thetriage: proposed closelabel.Generated by Claude Code
@reeledMarek on GitHub · 2026-11-26 05:43 UTC · original
Closing per triage and @lcg007xd-c's review: on x86-64 Windows the
usizeadditions insgd5cannot wrap andfile.get/Cursor::bytesalready reject oversized lengths, so the remainingskip_itemsrefactor alone does not justify a PR. Thanks for the thorough check!Pull request closed