App: reject wrapping RVAs in VICTORY_WATCH #482

Open
enzoduarte1 wants to merge 1 commit from upstream-pr/482 into main
enzoduarte1 commented 2026-11-24 03:55:52 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by enzoduarte1 on 2026-11-24T03:55:52Z.


What

watch() parsed each VICTORY_WATCH RVA as hex and checked it with rva + 4 <= size. On x86_64 a value like ffffffffffffffff wraps to 3, passes the check, and makes the polling thread read at base - 1 instead of inside the image. The neighboring VICTORY_CRASH_SAVE parser already uses checked_add.

The bounds check now uses checked_add, and the parsing lives in a watch_rvas helper that can be tested without reading an image. The test covers a wrapping RVA and the normal accepted/rejected boundary.

Tested

  • Windows 11, Rust 1.98.1, x86_64-pc-windows-gnu (no MSVC linker on this machine).
  • cargo test -p victory --features diagnostics --bin victory run::: 2 passed.
  • cargo test --workspace --exclude victory-loader -- --test-threads=1: all suites passed.
  • cargo clippy -p victory --all-targets --features diagnostics -- -D warnings: clean here, apart from the pre-existing xmem.rs warning fixed by PR #355, which was allowed locally.
  • rustfmt --edition 2024 --check apps/victory/src/run.rs and git diff --check: clean.
  • cargo xtask policy: 151 files ok. No game files or data taken from them were added.
  • Not tested: cargo test -p victory-loader --test load_probe. Its fixture passes MSVC's /DELAYLOAD flag, which MinGW rejects here; the same failure occurs on unmodified main.

Checklist

  • cargo fmt, cargo clippy --workspace --all-targets and cargo test --workspace pass — see the toolchain limitations above; the changed target is clean.
  • cargo xtask policy passes. The change adds no game files or data taken from them (docs/asset-policy.md).
  • If an AI tool wrote part of this change, the description says so: an AI tool assisted with the code and test; I reviewed and ran them.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6574253742 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/482). Originally posted by [enzoduarte1](https://github.com/enzoduarte1) on 2026-11-24T03:55:52Z. --- ## What `watch()` parsed each `VICTORY_WATCH` RVA as hex and checked it with `rva + 4 <= size`. On x86_64 a value like `ffffffffffffffff` wraps to `3`, passes the check, and makes the polling thread read at `base - 1` instead of inside the image. The neighboring `VICTORY_CRASH_SAVE` parser already uses `checked_add`. The bounds check now uses `checked_add`, and the parsing lives in a `watch_rvas` helper that can be tested without reading an image. The test covers a wrapping RVA and the normal accepted/rejected boundary. ## Tested - Windows 11, Rust 1.98.1, `x86_64-pc-windows-gnu` (no MSVC linker on this machine). - `cargo test -p victory --features diagnostics --bin victory run::`: 2 passed. - `cargo test --workspace --exclude victory-loader -- --test-threads=1`: all suites passed. - `cargo clippy -p victory --all-targets --features diagnostics -- -D warnings`: clean here, apart from the pre-existing `xmem.rs` warning fixed by PR #355, which was allowed locally. - `rustfmt --edition 2024 --check apps/victory/src/run.rs` and `git diff --check`: clean. - `cargo xtask policy`: 151 files ok. No game files or data taken from them were added. - Not tested: `cargo test -p victory-loader --test load_probe`. Its fixture passes MSVC's `/DELAYLOAD` flag, which MinGW rejects here; the same failure occurs on unmodified `main`. ## Checklist - [ ] `cargo fmt`, `cargo clippy --workspace --all-targets` and `cargo test --workspace` pass — see the toolchain limitations above; the changed target is clean. - [x] `cargo xtask policy` passes. The change adds no game files or data taken from them (`docs/asset-policy.md`). - [x] If an AI tool wrote part of this change, the description says so: an AI tool assisted with the code and test; I reviewed and ran them.
mercuryVM commented 2026-11-24 09:05:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T08:03:14Z.

Review: APPROVED


Tested c91e6b6 on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (264 passed, 0 failed). The new test only builds with --features diagnostics, and cargo test -p victory --features diagnostics --bin victory watch_rejects passes.

The bug is real. rva + 4 wraps for usize::MAX, so ffff…ff passed the bound and the poller would have read at base - 1. checked_add(4).is_some_and(|end| end <= size) fixes it and keeps the exact-fit boundary (0x1c with size 0x20 is accepted). Moving the parse into watch_rvas behind the same cfg keeps release builds unchanged.

No issues found.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6035624553 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/482#pullrequestreview-6035624553). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T08:03:14Z. **Review:** APPROVED --- Tested c91e6b6 on Windows 11, RTX 5070, MSVC: `cargo test --workspace --no-fail-fast` passes (264 passed, 0 failed). The new test only builds with `--features diagnostics`, and `cargo test -p victory --features diagnostics --bin victory watch_rejects` passes. The bug is real. `rva + 4` wraps for `usize::MAX`, so `ffff…ff` passed the bound and the poller would have read at `base - 1`. `checked_add(4).is_some_and(|end| end <= size)` fixes it and keeps the exact-fit boundary (`0x1c` with size `0x20` is accepted). Moving the parse into `watch_rvas` behind the same `cfg` keeps release builds unchanged. No issues found. AI-assisted (Claude Code).
Marvisak commented 2026-11-25 01:07:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:20:15Z.


Automated triage for the maintainers.

Needs rebase. This PR does not merge cleanly into current main (ac2525d). Conflicting files: apps/victory/src/run.rs.

The content has not been reviewed yet; it will be once the branch is rebased onto main.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148403361 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/482#issuecomment-7148403361). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:20:15Z. --- <!-- victory-triage v1 head=c91e6b6b20e3f9e4561286a7e23fb1c196397df9 verdict=needs-rebase at=2026-11-25T00:13:20Z --> Automated triage for the maintainers. **Needs rebase.** This PR does not merge cleanly into current `main` (ac2525d). Conflicting files: `apps/victory/src/run.rs`. The content has not been reviewed yet; it will be once the branch is rebased onto `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/482:upstream-pr/482'
git switch 'upstream-pr/482'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/482'
git switch 'upstream-pr/482'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/482'
git switch 'upstream-pr/482'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/482'
git switch 'main'
git merge --squash 'upstream-pr/482'
git switch 'main'
git merge --ff-only 'upstream-pr/482'
git switch 'main'
git merge 'upstream-pr/482'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!482
No description provided.