HLE rpcrt4: fix GUID brace parsing and UuidToString OOM handling #3376
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3376"
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?
Imported from Marvisak/VIctory. Originally posted by Arkenoz on 2026-11-26T20:55:18Z.
Tracked in #1633.
Problem
parse()incrates/victory-hle/src/modules/rpcrt4.rsaccepted trailing characters after a closing}(returning immediately without checking that the iterator was exhausted), unmatched braces ({...or...}), and repeated opening braces ({{...}).UuidToStringAandUuidToStringWignored allocation failure fromallocate(), writing a null pointer tooutand returningOKinstead ofOUT_OF_MEMORY.Changes
{was seen inparse(), rejecting repeated{, unmatched braces, and any trailing characters after}.allocate(&bytes)for null inUuidToStringAandUuidToStringW, returningOUT_OF_MEMORYwithout writing toout.garbage_is_refusedfor 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.
Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T21:09:32Z.
Review: APPROVED
LGTM — verified on Windows against
origin/main(63bcca4).OUT_OF_MEMORYon null allocation inUuidToStringA/UuidToStringWand rejecting mismatched/duplicate braces or trailing garbage inparsecleanly hardensrpcrt4.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).
Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-11-26T21:31:36Z.
I ran the Windows differential test from #1975 against both PR heads. With 64-bit System32 rpcrt4.dll 10.0.26100.9949, it passes on
72a7ec1f(#1975) and fails on99bd788d(this PR) at the null input. A separate non-short-circuiting matrix checks both the status and the complete 16-byte destination, initialized to a sentinel. ANSI and UTF-16 agreed in every row.That is 12/12 matching native rows for #1975 and 6/12 for this head. For parsing parity I would keep #1975's exact grammar and null-input behavior when reconciling the patches. This exercise did not inject allocation failure into UuidToString. Each PR was built in a separate Cargo target directory. Synthetic inputs only.
AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by Arkenoz on 2026-11-27T00:16:08Z.
Thanks for running the native Windows comparison! Updated
UuidFromStringA,UuidFromStringW, andparse()to match nativerpcrt4.dllbehavior across all 12 cases:uuidnow writes the nil UUID and returnsOK.parse()now enforces strict canonical 36-char8-4-4-4-12hex grammar (rejecting braces, hyphenless/misplaced-hyphen strings, trailing characters, and empty strings) while leavinguuiduntouched onINVALID_STRING_UUID.OUT_OF_MEMORYchecks inUuidToStringA/UuidToStringW.UuidFromStringAandUuidFromStringW(cargo test -p victory-hle rpcrt4— 7 passed,clippy -D warningsclean).Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T01:11:06Z.
Review: APPROVED
Looks good. Verified
UuidFromStringA/Wdirectly against native Windows 11rpcrt4.dllacross 12 test vectors (null pointer returningRPC_S_OKwith nil UUID, empty string, lowercase/uppercase canonical UUIDs, braced UUIDs, braced + trailing text, missing/misplaced hyphens, leading/trailing whitespace, unmatched braces) with 0 mismatches on both return codes and outputGuidpreservation. TheUuidToStringA/Wnull-allocation check returningRPC_S_OUT_OF_MEMORYbefore writing*outis also clean.Verified:
cargo xtask policypasses cleanly.cargo clippy --tests -p victory-hle(default and--features diagnostics,-D warnings) passes with zero warnings.cargo test --locked -p victory-hle --lib modules::rpcrt4::passes (7/7).Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-11-29T16:22:20Z.
Re-ran the same native Windows differential on
1f1a3d6f7fc857d0f0c6cfe252c81f62add9e5d4. All 12/12 rows now match System32rpcrt4.dllfor both return code and the full 16-byte destination, up from 6/12 on99bd788d359505d738770777e503bab89931b3aa. The matrix coversUuidFromStringAandUuidFromStringW, each with null input, canonical text, braces, braces with trailing text, omitted hyphens, and an empty string. Outputs start as a nonzero sentinel in every case.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.