HLE: report required size on string getter buffer errors #446

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

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


What

xgameruntime::put_string returned E_NOT_SUFFICIENT_BUFFER without touching used when the title passed no buffer (or one that was too small). String getters in this runtime use the usual two-call pattern — call with no buffer to learn the required size, then call again with that buffer — so the first call could not get an answer.

The error branch now writes text.len() + 1 through used when it is non-null, and leaves the buffer untouched on failure. Exact-fit and null-used behavior are unchanged. A test covers the size query, the follow-up fetch, a short buffer and a caller that does not ask for the size.

Tested

  • Windows 11, Rust 1.98.1, x86_64-pc-windows-gnu (no MSVC linker on this machine).
  • cargo test -p victory-hle --lib xgameruntime::: 2 passed.
  • cargo test --workspace --exclude victory-loader -- --test-threads=1: all suites passed.
  • cargo clippy -p victory-hle --all-targets -- -A clippy::field_reassign_with_default -D warnings: clean. The allowed lint is the pre-existing warning fixed by PR #355.
  • rustfmt --edition 2024 --check crates/victory-hle/src/modules/xgameruntime.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 crate 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:6573976166 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/446). Originally posted by [enzoduarte1](https://github.com/enzoduarte1) on 2026-11-24T03:30:44Z. --- ## What `xgameruntime::put_string` returned `E_NOT_SUFFICIENT_BUFFER` without touching `used` when the title passed no buffer (or one that was too small). String getters in this runtime use the usual two-call pattern — call with no buffer to learn the required size, then call again with that buffer — so the first call could not get an answer. The error branch now writes `text.len() + 1` through `used` when it is non-null, and leaves the buffer untouched on failure. Exact-fit and null-`used` behavior are unchanged. A test covers the size query, the follow-up fetch, a short buffer and a caller that does not ask for the size. ## Tested - Windows 11, Rust 1.98.1, `x86_64-pc-windows-gnu` (no MSVC linker on this machine). - `cargo test -p victory-hle --lib xgameruntime::`: 2 passed. - `cargo test --workspace --exclude victory-loader -- --test-threads=1`: all suites passed. - `cargo clippy -p victory-hle --all-targets -- -A clippy::field_reassign_with_default -D warnings`: clean. The allowed lint is the pre-existing warning fixed by PR #355. - `rustfmt --edition 2024 --check crates/victory-hle/src/modules/xgameruntime.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 crate 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 06:53:05 +00:00 (Migrated from github.com)

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

Review: APPROVED


Tested 881caef on Windows 11, RTX 5070, MSVC: cargo test --workspace --no-fail-fast passes (265 passed, 0 failed).

  • I checked every put_string caller (storage.rs, xsystem.rs ×3, xuser.rs, xpackage.rs, xstore.rs). None reads used after a failure or depends on it staying unchanged. The two that pass a null used are unaffected.
  • The buffer is still untouched on failure, and the new test checks that with the 0xff fill.

No issues found.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6034060458 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/446#pullrequestreview-6034060458). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T05:14:16Z. **Review:** APPROVED --- Tested 881caef on Windows 11, RTX 5070, MSVC: `cargo test --workspace --no-fail-fast` passes (265 passed, 0 failed). - I checked every `put_string` caller (`storage.rs`, `xsystem.rs` ×3, `xuser.rs`, `xpackage.rs`, `xstore.rs`). None reads `used` after a failure or depends on it staying unchanged. The two that pass a null `used` are unaffected. - The buffer is still untouched on failure, and the new test checks that with the `0xff` fill. No issues found. AI-assisted (Claude Code).
Marvisak commented 2026-11-25 01:07:56 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers.

Needs work. This changes a runtime return value: put_string in crates/victory-hle/src/modules/xgameruntime.rs would write the required size through used on E_NOT_SUFFICIENT_BUFFER. Its callers (xsystem.rs, xuser.rs, storage.rs) implement getters whose public documentation describes fixed-size buffers with documented maximum sizes; none is documented as call-once-to-get-the-size, and the docs don't say used is written on failure. Please add evidence that the real runtime writes used on this error (public documentation for a specific getter, or the title's call sites relying on it) and name the caller that needs it.

CI: no check runs on the head commit.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148576872 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/446#issuecomment-7148576872). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:30:16Z. --- <!-- victory-triage v1 head=881caef98fa0e2e08c4b37fd1f6e2d759aa2f40c verdict=needs-work at=2026-11-25T00:22:34Z --> Automated triage for the maintainers. **Needs work.** This changes a runtime return value: `put_string` in `crates/victory-hle/src/modules/xgameruntime.rs` would write the required size through `used` on `E_NOT_SUFFICIENT_BUFFER`. Its callers (`xsystem.rs`, `xuser.rs`, `storage.rs`) implement getters whose public documentation describes fixed-size buffers with documented maximum sizes; none is documented as call-once-to-get-the-size, and the docs don't say `used` is written on failure. Please add evidence that the real runtime writes `used` on this error (public documentation for a specific getter, or the title's call sites relying on it) and name the caller that needs it. CI: no check runs on the head commit. --- _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/446:upstream-pr/446'
git switch 'upstream-pr/446'

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/446'
git switch 'upstream-pr/446'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/446'
git switch 'upstream-pr/446'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/446'
git switch 'main'
git merge --squash 'upstream-pr/446'
git switch 'main'
git merge --ff-only 'upstream-pr/446'
git switch 'main'
git merge 'upstream-pr/446'
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!446
No description provided.