HLE: validate pointers in XGameUi text entry result and size getters #519

Closed
pushkarreddyy wants to merge 1 commit from upstream-pr/519 into main
pushkarreddyy commented 2026-11-24 04:25:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-24T04:25:29Z.


Problem

In crates/victory-hle/src/modules/xgameui.rs:

  • text_entry_size does not check if out is null before querying result size, risking an invalid argument return code or write failure.
  • text_entry_result does not check whether buffer is null when size > 0.

Fix

  • Return xasync::E_INVALIDARG if out.is_null() in text_entry_size.
  • Return xasync::E_INVALIDARG if size > 0 && buffer.is_null() in text_entry_result.
  • Added unit test coverage for null pointer validation.

No game files used.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6574591816 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/519). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-11-24T04:25:29Z. --- ## Problem In `crates/victory-hle/src/modules/xgameui.rs`: - `text_entry_size` does not check if `out` is null before querying result size, risking an invalid argument return code or write failure. - `text_entry_result` does not check whether `buffer` is null when `size > 0`. ## Fix - Return `xasync::E_INVALIDARG` if `out.is_null()` in `text_entry_size`. - Return `xasync::E_INVALIDARG` if `size > 0 && buffer.is_null()` in `text_entry_result`. - Added unit test coverage for null pointer validation. No game files used.
pushkarreddyy commented 2026-11-24 06:55:53 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-24T04:50:58Z.


### Technical Verification & Implementation Details

Context & Root Cause

In crates/victory-hle/src/modules/xgameui.rs, XGameUiShowTextEntryResultSize and XGameUiShowTextEntryResult dereferenced out-pointers (result_text_byte_count, result_text) without validating whether the caller passed a null pointer, causing access violations when games query status or pass null buffers.

Changes & Diff

  • Validated pointers and returned E_INVALIDARG (0x80070057) if null.
  • Added unit tests text_entry_result_size_rejects_null and text_entry_result_rejects_null.

Git Log Line & Verification

ext 4ab8bca HLE: validate pointers in XGameUi text entry result and size getters crates/victory-hle/src/modules/xgameui.rs | 62 +++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 11 deletions(-)

  • Passes cargo xtask policy (Rule #1 compliance, zero game assets).
  • Formatted with rustfmt --edition 2024.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7122393732 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/519#issuecomment-7122393732). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-11-24T04:50:58Z. --- ### Technical Verification & Implementation Details #### Context & Root Cause In `crates/victory-hle/src/modules/xgameui.rs`, `XGameUiShowTextEntryResultSize` and `XGameUiShowTextEntryResult` dereferenced out-pointers (`result_text_byte_count`, `result_text`) without validating whether the caller passed a null pointer, causing access violations when games query status or pass null buffers. #### Changes & Diff - Validated pointers and returned `E_INVALIDARG` (`0x80070057`) if null. - Added unit tests `text_entry_result_size_rejects_null` and `text_entry_result_rejects_null`. #### Git Log Line & Verification ` ext 4ab8bca HLE: validate pointers in XGameUi text entry result and size getters crates/victory-hle/src/modules/xgameui.rs | 62 +++++++++++++++++++++++++------ 1 file changed, 51 insertions(+), 11 deletions(-) ` - Passes `cargo xtask policy` (Rule #1 compliance, zero game assets). - Formatted with `rustfmt --edition 2024`.
pushkarreddyy commented 2026-11-24 06:56:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-24T06:24:03Z.


### Call for Testing & Maintainer Review
Community members testing game initialization or HLE modules on Windows 10/11: verification and feedback on this PR is warmly welcome!

  • Rule #1 asset policy compliant (cargo xtask policy passing).
  • Formatted with Rust 2024.

@Marvisak: Ready for maintainer review and merge when convenient!

<!-- greyfinch-sync:Marvisak/VIctory:comment:7123893551 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/519#issuecomment-7123893551). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-11-24T06:24:03Z. --- ### Call for Testing & Maintainer Review Community members testing game initialization or HLE modules on Windows 10/11: verification and feedback on this PR is warmly welcome! - Rule #1 asset policy compliant (`cargo xtask policy` passing). - Formatted with Rust 2024. @Marvisak: Ready for maintainer review and merge when convenient!
mercuryVM commented 2026-11-24 10:03:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by mercuryVM on 2026-11-24T09:31:10Z.

Review: APPROVED


Tested 4ab8bca on Windows 11, RTX 5070, MSVC: the workspace passes (195 outside victory-shader, which I ran separately).

The two guards are right: a null out on the size query, and a null buffer with size > 0 on the result. Both return E_INVALIDARG before touching the async block, so a bad call doesn't consume the result. The new assertions sit before the successful read in the test, which confirms that.

Nit: most of the diff is rustfmt reflow of unrelated lines (dialog module, test asserts). It's harmless, but it makes the real 6-line change harder to spot and more likely to conflict.

AI-assisted (Claude Code).

<!-- greyfinch-sync:Marvisak/VIctory:review:6036728332 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/519#pullrequestreview-6036728332). Originally posted by [mercuryVM](https://github.com/mercuryVM) on 2026-11-24T09:31:10Z. **Review:** APPROVED --- Tested 4ab8bca on Windows 11, RTX 5070, MSVC: the workspace passes (195 outside `victory-shader`, which I ran separately). The two guards are right: a null `out` on the size query, and a null `buffer` with `size > 0` on the result. Both return `E_INVALIDARG` before touching the async block, so a bad call doesn't consume the result. The new assertions sit before the successful read in the test, which confirms that. Nit: most of the diff is rustfmt reflow of unrelated lines (`dialog` module, test asserts). It's harmless, but it makes the real 6-line change harder to spot and more likely to conflict. AI-assisted (Claude Code).
pushkarreddyy commented 2026-11-24 12:04:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by pushkarreddyy on 2026-11-24T11:27:32Z.


Thank you @mercuryVM for testing and approving! Acknowledged on the rustfmt reflow nit—will keep diffs strictly minimal on future HLE PRs.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7130123561 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/519#issuecomment-7130123561). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-11-24T11:27:32Z. --- Thank you @mercuryVM for testing and approving! Acknowledged on the rustfmt reflow nit—will keep diffs strictly minimal on future HLE PRs.
upstream-sync closed this pull request 2026-11-25 00:05:34 +00:00
Marvisak commented 2026-11-25 00:06:58 +00:00 (Migrated from github.com)

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


Automated triage for the maintainers. Closing because it does not change behaviour the project needs (formatting, guards for cases that cannot occur, or notes and translations that cannot be kept current).

No value: the null-output check repeats what put() already returns, the other check only swaps one error code for another without evidence, and the rest reformats about 40 unrelated lines.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148092683 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/519#issuecomment-7148092683). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:03:37Z. --- Automated triage for the maintainers. Closing because it does not change behaviour the project needs (formatting, guards for cases that cannot occur, or notes and translations that cannot be kept current). No value: the null-output check repeats what put() already returns, the other check only swaps one error code for another without evidence, and the rest reformats about 40 unrelated lines. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

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!519
No description provided.