XGameSave: a "%" in a save folder name is decoded by bytes, not by slicing the str (#325) #442
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!442
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/442/head"
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?
@Rednaxeh on GitHub · 2026-11-24 00:21 UTC · original
Rednaxeh:gamesave-percent-decode→main· +37 −6 · 1 files · 1 commits · closed without mergingdecingamesave.rsturned%XXback into a byte by slicing the name at byte offsets and parsing withfrom_str_radix. A folder or file name with%, a hex digit and then a multi-byte character (%aé) made the slice end inside the character and panic;decruns on every name in the save provider's folder fromextern "system"entry points, so the panic cannot unwind andXGameSaveEnumerateContainerInfoended the title with0xC0000409. XCL'sencnever writes such a name, but a save folder restored from a backup or edited by hand can hold one.from_str_radixalso accepted a sign, so%+1decoded to the byte 1. Fixes #325.What is in it
crates/xcl/src/hle/xgameruntime/gamesave.rs:decreads the two bytes after%and decodes them only when both are hex digits; anything else is kept as it is. Two tests in the file'smod tests:dec_keeps_a_percent_without_two_hex_digits(%aé,%+1, a trailing%, and anenc/decround trip) anda_container_folder_named_percent_then_multibyte_is_enumerated(a hand-placed%aécontainer folder goes throughXGameSaveEnumerateContainerInfo).Tested
stable-x86_64-pc-windows-msvc, debug (release for the regression run); DXC 1.9.2602.17.main'sdec):dec_keeps_a_percent_without_two_hex_digitspanics atgamesave.rs:100:52(end byte index 3 is not a char boundary; it is inside 'é');a_container_folder_named_percent_then_multibyte_is_enumeratedaborts the test process (thread caused non-unwinding panic. aborting., exit code0xC0000409).cargo test -p xcl --lib -- hle::xgameruntime::gamesave::: 12 passed, 0 failed..\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4) withXCL_REQUIRE_GPU=wave64,mesh: 672 passed, 0 failed, 41 ignored, 0 SKIPPED.Regression run
scripts/smoke.ps1 -Game <folder>on a retail title, release builds, no uncommitted changes, one after the other on the machine above (a warm-up run ofmainfirst, not shown). Thegpu:line names the wrong adapter (the script's known issue); the GPU was the RX 7800 XT. Both blocks unedited.main3516080:this PR's head
e310370:Not tested
AI use
🤖 Generated with Claude Code
`dec` turned "%XX" back into a byte with `u8::from_str_radix(&file[i + 1..i + 3], 16)`. Slicing the name at byte offsets panics when a multi-byte character follows the hex digit ("%aé": "end byte index 3 is not a char boundary"), and `dec` runs on every folder and file name of the save provider from `extern "system"` entry points, where the panic cannot unwind: XGameSaveEnumerateContainerInfo over such a folder ends the title with 0xC0000409. XCL's own `enc` never writes such a name; a folder restored from a backup or placed by hand can have one. `from_str_radix` also took a sign, so "%+1" decoded to the byte 1. The two characters after "%" are now read as bytes and must both be hex digits; anything else stays as it is. Fixes #325. Co-Authored-By: Claude Fable 5.1 <[email protected]>@ivall on GitHub · 2026-11-24 11:20 UTC · original
Closing in favor of #448 for #325. The comparison in #325 reports equivalent decoding behavior; #448 also includes an enumeration-level regression test and broader malformed-escape and round-trip cases. The fix remains unmerged. Thank you for the contribution.
Pull request closed