HLE rpcrt4: fix GUID brace parsing and UuidToString OOM handling #3376

Open
github-bot wants to merge 1 commit from github-bot/gh-3376 into main AGit
Owner

@⁠Arkenoz on GitHub · 2026-11-26 20:55 UTC · original
Arkenoz:fix/rpcrt4-parse-oom → main · +38 −5 · 1 files · 1 commits · open

Tracked in #1633.

Problem

  1. parse() in crates/victory-hle/src/modules/rpcrt4.rs accepted trailing characters after a closing } (returning immediately without checking that the iterator was exhausted), unmatched braces ({... or ...}), and repeated opening braces ({{...}).
  2. UuidToStringA and UuidToStringW ignored allocation failure from allocate(), writing a null pointer to out and returning OK instead of OUT_OF_MEMORY.

Changes

  • Tracked whether an opening { was seen in parse(), rejecting repeated {, unmatched braces, and any trailing characters after }.
  • Checked allocate(&bytes) for null in UuidToStringA and UuidToStringW, returning OUT_OF_MEMORY without writing to out.
  • Added unit test cases in garbage_is_refused for trailing characters after }, unmatched braces, and duplicate opening braces.

Verification

  • cargo test -p victory-hle rpcrt4 (5 passed)
  • cargo clippy -p victory-hle --all-targets (0 warnings)

AI-assisted with Gemini.

**@⁠Arkenoz** on GitHub · 2026-11-26 20:55 UTC · [original](https://github.com/Marvisak/VIctory/pull/3376) `Arkenoz:fix/rpcrt4-parse-oom` → `main` · +38 −5 · 1 files · 1 commits · open Tracked in #1633. ### Problem 1. `parse()` in `crates/victory-hle/src/modules/rpcrt4.rs` accepted trailing characters after a closing `}` (returning immediately without checking that the iterator was exhausted), unmatched braces (`{...` or `...}`), and repeated opening braces (`{{...}`). 2. `UuidToStringA` and `UuidToStringW` ignored allocation failure from `allocate()`, writing a null pointer to `out` and returning `OK` instead of `OUT_OF_MEMORY`. ### Changes - Tracked whether an opening `{` was seen in `parse()`, rejecting repeated `{`, unmatched braces, and any trailing characters after `}`. - Checked `allocate(&bytes)` for null in `UuidToStringA` and `UuidToStringW`, returning `OUT_OF_MEMORY` without writing to `out`. - Added unit test cases in `garbage_is_refused` for trailing characters after `}`, unmatched braces, and duplicate opening braces. ### Verification - `cargo test -p victory-hle rpcrt4` (5 passed) - `cargo clippy -p victory-hle --all-targets` (0 warnings) AI-assisted with Gemini.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:00:53 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 21:09 UTC · original · approved these changes

LGTM — verified on Windows against origin/main (63bcca4).

  • Returning OUT_OF_MEMORY on null allocation in UuidToStringA/UuidToStringW and rejecting mismatched/duplicate braces or trailing garbage in parse cleanly hardens rpcrt4.
  • cargo test -p victory-hle --lib modules::rpcrt4:: -- --test-threads=1: 5 passed, 0 failed.
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-26 21:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/3376#pullrequestreview-6080503039) · **approved these changes** LGTM — verified on Windows against `origin/main` (`63bcca4`). - Returning `OUT_OF_MEMORY` on null allocation in `UuidToStringA`/`UuidToStringW` and rejecting mismatched/duplicate braces or trailing garbage in `parse` cleanly hardens `rpcrt4`. - `cargo test -p victory-hle --lib modules::rpcrt4:: -- --test-threads=1`: 5 passed, 0 failed. - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3376/head:github-bot/gh-3376'
git switch 'github-bot/gh-3376'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3376'
git switch 'github-bot/gh-3376'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3376'
git switch 'github-bot/gh-3376'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3376'
git switch 'main'
git merge --squash 'github-bot/gh-3376'
git switch 'main'
git merge --ff-only 'github-bot/gh-3376'
git switch 'main'
git merge 'github-bot/gh-3376'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!3376
No description provided.