Files: .. on a virtual drive stops at its root in short paths too (G:\..\x left the package folder) #258

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

@⁠sharan104 on GitHub · 2026-11-26 13:32 UTC · original
sharan104:fix/files-audit → main · +59 −1 · 1 files · 1 commits · open

A virtual drive's root is the root of a drive to the title, so X:\.. is X:\ again. translate() already handles this for long paths: anything of 248 characters or more goes through verbatim(), which stops .. at the root. But a short path was joined to the host folder as it came, and the host's own clean-up then climbed above that folder. So:

  • G:\..\x opened x beside the package folder instead of G:\x.
  • .. from the persistent-storage drive reached the data directory around the title's storage folder.
  • The same title path landed in different folders depending on its length.

This affects every title path call that goes through translate(): CreateFileW, fopen, GetFileAttributesW and the rest.

Fix: a short path now drops each .. that would climb above the root (within_root) before the host sees it. Everything else is still left to the host's clean-up, as before. \\?\ paths, which the host doesn't clean up, are unchanged.

Only an exact .. component climbs. I checked GetFullPathNameW on Windows 11: .. , ..., .. . and .. are kept as literal names, or trimmed when they're the last part, and none of them goes up a level. So matching exactly .. covers every spelling that climbs.

Test: dot_dot_stays_on_the_drive checks the rewritten strings. It also checks real GetFileAttributesW calls against a mounted temp folder: X:\..\outside.txt is not found, while X:\..\inside.txt and X:/a/../../inside.txt are found. It fails before the change, where the host path keeps inner\..\a, and passes after it.

Results:

  • cargo test -p victory-hle --locked: 156 passed, 0 failed, 2 ignored. The new test passed 10 out of 10 runs.
  • cargo clippy -p victory-hle --all-targets --locked --no-deps -- -D warnings is clean, with and without --all-features.

🤖 Generated with Claude Code

**@⁠sharan104** on GitHub · 2026-11-26 13:32 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/258) `sharan104:fix/files-audit` → `main` · +59 −1 · 1 files · 1 commits · open A virtual drive's root is the root of a drive to the title, so `X:\..` is `X:\` again. `translate()` already handles this for long paths: anything of 248 characters or more goes through `verbatim()`, which stops `..` at the root. But a **short** path was joined to the host folder as it came, and the host's own clean-up then climbed above that folder. So: - `G:\..\x` opened `x` beside the package folder instead of `G:\x`. - `..` from the persistent-storage drive reached the data directory around the title's storage folder. - The same title path landed in different folders depending on its length. This affects every title path call that goes through `translate()`: `CreateFileW`, `fopen`, `GetFileAttributesW` and the rest. **Fix:** a short path now drops each `..` that would climb above the root (`within_root`) before the host sees it. Everything else is still left to the host's clean-up, as before. `\\?\` paths, which the host doesn't clean up, are unchanged. Only an exact `..` component climbs. I checked `GetFullPathNameW` on Windows 11: `.. `, `...`, `.. .` and `.. ` are kept as literal names, or trimmed when they're the last part, and none of them goes up a level. So matching exactly `..` covers every spelling that climbs. **Test:** `dot_dot_stays_on_the_drive` checks the rewritten strings. It also checks real `GetFileAttributesW` calls against a mounted temp folder: `X:\..\outside.txt` is not found, while `X:\..\inside.txt` and `X:/a/../../inside.txt` are found. It fails before the change, where the host path keeps `inner\..\a`, and passes after it. **Results:** - `cargo test -p victory-hle --locked`: 156 passed, 0 failed, 2 ignored. The new test passed 10 out of 10 runs. - `cargo clippy -p victory-hle --all-targets --locked --no-deps -- -D warnings` is clean, with and without `--all-features`. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A virtual drive's root is the root of a drive to the title, so `X:\..`
is `X:\` again. The long-path branch of `translate` already resolves `..`
so that it stops at the root, but a short path was joined to the host
folder as it came, and the host's own clean-up then climbed above the
folder: `G:\..\x` opened `x` beside the package folder, and `..` from
the persistent storage drive reached the data directory around it. The
same title path landed in different folders depending on its length.

A short path now drops each `..` that would climb above the root before
the host sees it; everything else is left to the host's clean-up as
before. `\\?\` paths, which the host does not clean up, are unchanged.

The new test dot_dot_stays_on_the_drive fails before this change (the
host path keeps `inner\..\a`) and passes after it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 13:32:40 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
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/258/head:github-bot/gh-258'
git switch 'github-bot/gh-258'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-258'
git switch 'github-bot/gh-258'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-258'
git switch 'github-bot/gh-258'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-258'
git switch 'main'
git merge --squash 'github-bot/gh-258'
git switch 'main'
git merge --ff-only 'github-bot/gh-258'
git switch 'main'
git merge 'github-bot/gh-258'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.