Skip to content

XGameSave: decode %XX in save file names without slicing the name (#325) - #457

Closed
raulmesa96 wants to merge 1 commit into
xcl-dev:mainfrom
raulmesa96:xgamesave-dec-no-panic
Closed

raulmesa96 wants to merge 1 commit into
xcl-dev:mainfrom
raulmesa96:xgamesave-dec-no-panic

Conversation

@raulmesa96

Copy link
Copy Markdown

dec in gamesave.rs sliced the save file name by byte index after a %; a name with a multi-byte character right after %x panicked inside an extern "system" call and aborted the process. It now reads the two digits as bytes, and both must be hex digits (so %+1 / %-1 are no longer decoded). Names XCL writes itself (enc) decode as before.

Fixes #325

What is in it

  • dec reads the escape's digits as bytes – crates/xcl/src/hle/xgameruntime/gamesave.rs
  • unit test dec_keeps_percent_not_followed_by_two_hex_digits (panicked with end byte index 3 is not a char boundary before the fix) – same file

Tested

  • NVIDIA GeForce RTX 3060 (driver 32.0.16.1088), Intel Core i5-12600K, Windows 11 25H2 build 26200, Rust 1.100.0 x86_64-pc-windows-msvc, debug
  • head aebea99 on main a6f5f7a, clean tree
  • cargo build --workspace then cargo test --workspace --no-fail-fast -- --test-threads=4: 677 passed, 0 failed, 41 ignored (the xcl lib: 637 passed, 0 failed, 21 ignored)
  • SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64)
  • cargo test -p xcl --lib gamesave: 11 passed, 0 failed

Regression run

  • none: I have no Xbox title to run scripts/smoke.ps1 on. The change is limited to dec (decoding save file names) and is covered by the unit tests and the full suite above; I would be grateful if someone with a title could add the two xcl-smoke blocks.

Not tested

  • the regression run on a real title (see above)
  • AMD GPUs
  • a retail title writing or reading saves with such names

AI use

  • Claude Code with Claude Opus 5.5: wrote the fix, the test and this description; the tests above were run by it on the hardware named.

🤖 Generated with Claude Code

…l-dev#325)

`dec` sliced `&file[i + 1..i + 3]` by byte index, so a name in the save
folder with '%', an ASCII byte and then a multi-byte character (e.g.
"%aé", copied there by hand or by another tool) panicked on a char
boundary. `dec` runs during enumeration and reads from `extern "system"`
functions, where the panic aborts the process. The two digits are now
read as bytes and must both be hex digits, which also stops
`from_str_radix` from taking a sign ("%+1" was decoded as 0x01).

Fixes xcl-dev#325

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@raylitebull

Copy link
Copy Markdown
Member

Closing as a duplicate of #442 / #448 for #325, which pass the PR description check (whereas this PR fails PR description).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XGameSave: a save file name with a non-ASCII character after '%' panics in an extern "system" call

2 participants