Files: .. in a title path stops at the virtual drive's root #182

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

@⁠Maraco91 on GitHub · 2026-11-24 01:12 UTC · original
Maraco91:files/dotdot-stops-at-drive-root → main · +90 −6 · 1 files · 1 commits · open

What

A title path with .. could name a file outside the host folder behind its virtual drive.

translate hands a short path to the host as the host folder followed by the title's tail, unchanged. The host then resolves .. against the host folder, which has a parent: with a drive over C:\data\title, X:\..\outside.bin becomes C:\data\title\..\outside.bin, and CreateFileW makes C:\data\outside.bin. To the title X:\ is a drive root, where .. stops: the path is X:\outside.bin (as C:\..\x is C:\x on the host). The same goes for X:\a\..\..\b, X:/../b and X:..\b.

The long form already does this: verbatim() resolves . and .. itself and ".. stops at the root" (the existing test checks /x/../../y). So today the same title path names different host files depending on whether root + tail reaches 248 characters.

Now a tail with a .. part is resolved here in the short form too, with the same clean-up (moved out of verbatim() into parts(), unchanged), and written as the host folder plus the names left. A trailing separator is kept, and X:\.. is the root (<root>\). Paths without a .. part are passed on exactly as before, / and all. Paths given with \?\ are untouched: after that prefix .. is a name to the host too.

I have not seen a title build such a path (I have no game files); this is from reading the code. Both drives a title writes through (T:, persistent storage) and the package drive go through this function.

Tested

Windows 11 Pro 10.0.26200, rustc 1.98.1 (x86_64-pc-windows-msvc), no game data, no GPU involved.

New unit test parent_parts_stop_at_the_drive_root: mounts <temp>\title, calls CreateFileW on X:\..\outside.bin and checks the file is in <temp>\title and not in <temp>; then checks translate on seven paths (\..\, /../, drive-relative ..\, several levels, with ., a trailing separator, the bare X:\..). Controls in the same test: X:\a\..\b.bin still names <root>\b.bin, and names that merely contain dots (a..b, ..c) are passed on unchanged.

  • main (d2a4bae) + the test only: cargo test -p victory-hle --lib parent_parts fails: left the drive (the file was created in <temp>, beside the drive's folder).
  • with the fix: cargo test -p victory-hle --lib files::: 5 passed, 0 failed (the 4 existing files tests, among them the long-path ones that go through verbatim(), and the new one).
  • cargo clippy -p victory-hle --tests: nothing in files.rs. rustfmt --check files.rs: nothing in the lines changed (one existing difference at the ReadFile assertion in kernel_reads_reach_the_buffer).
  • cargo xtask policy --staged: ok.

Not tested: a title run.

Touches translate/verbatim only; #111 (narrow wrappers) and #133 (mount_at) change other parts of the file.

AI-assisted (Claude Code); the tests above were run on the machine described.

🤖 Generated with Claude Code

**@⁠Maraco91** on GitHub · 2026-11-24 01:12 UTC · [original](https://github.com/Marvisak/VIctory/pull/182) `Maraco91:files/dotdot-stops-at-drive-root` → `main` · +90 −6 · 1 files · 1 commits · open ## What A title path with `..` could name a file outside the host folder behind its virtual drive. `translate` hands a short path to the host as the host folder followed by the title's tail, unchanged. The host then resolves `..` against the host folder, which has a parent: with a drive over `C:\data\title`, `X:\..\outside.bin` becomes `C:\data\title\..\outside.bin`, and `CreateFileW` makes `C:\data\outside.bin`. To the title `X:\` is a drive root, where `..` stops: the path is `X:\outside.bin` (as `C:\..\x` is `C:\x` on the host). The same goes for `X:\a\..\..\b`, `X:/../b` and `X:..\b`. The long form already does this: `verbatim()` resolves `.` and `..` itself and "`..` stops at the root" (the existing test checks `/x/../../y`). So today the same title path names different host files depending on whether root + tail reaches 248 characters. Now a tail with a `..` part is resolved here in the short form too, with the same clean-up (moved out of `verbatim()` into `parts()`, unchanged), and written as the host folder plus the names left. A trailing separator is kept, and `X:\..` is the root (`<root>\`). Paths without a `..` part are passed on exactly as before, `/` and all. Paths given with `\?\` are untouched: after that prefix `..` is a name to the host too. I have not seen a title build such a path (I have no game files); this is from reading the code. Both drives a title writes through (`T:`, persistent storage) and the package drive go through this function. ## Tested Windows 11 Pro 10.0.26200, rustc 1.98.1 (`x86_64-pc-windows-msvc`), no game data, no GPU involved. New unit test `parent_parts_stop_at_the_drive_root`: mounts `<temp>\title`, calls `CreateFileW` on `X:\..\outside.bin` and checks the file is in `<temp>\title` and not in `<temp>`; then checks `translate` on seven paths (`\..\`, `/../`, drive-relative `..\`, several levels, with `.`, a trailing separator, the bare `X:\..`). Controls in the same test: `X:\a\..\b.bin` still names `<root>\b.bin`, and names that merely contain dots (`a..b`, `..c`) are passed on unchanged. - `main` (d2a4bae) + the test only: `cargo test -p victory-hle --lib parent_parts` **fails**: `left the drive` (the file was created in `<temp>`, beside the drive's folder). - with the fix: `cargo test -p victory-hle --lib files::`: **5 passed, 0 failed** (the 4 existing files tests, among them the long-path ones that go through `verbatim()`, and the new one). - `cargo clippy -p victory-hle --tests`: nothing in `files.rs`. `rustfmt --check files.rs`: nothing in the lines changed (one existing difference at the `ReadFile` assertion in `kernel_reads_reach_the_buffer`). - `cargo xtask policy --staged`: ok. Not tested: a title run. Touches `translate`/`verbatim` only; #111 (narrow wrappers) and #133 (`mount_at`) change other parts of the file. AI-assisted (Claude Code); the tests above were run on the machine described. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A path on a virtual drive was handed to the host as the host folder
followed by the title's tail, so the host resolved `..` against the host
folder: `X:\..\f` named a file beside the drive's folder, where on a
drive of its own `..` stops at the root and the path is `X:\f`. Long
paths (the `\?\` form) already resolved `..` here and stopped at the
root, so the same title path named different files depending on its
length.

A tail with a `..` part is now resolved here in the short form too, with
the clean-up the long form uses. Other paths are passed on as before.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:53:38 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 01:24 UTC · original

Tested 1827532 under Wine 11.22 + vkd3d-proton 3.1 on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with cargo xwin ... --target x86_64-pc-windows-msvc -p victory-hle and a native Microsoft d3dcompiler_47: pass.

  • victory_hle: 86 passed, 1 failed — the failure is modules::net::tests::only_loopback_is_reachable (Wine lacks WSAConnectByList, as in #118), not this PR. The test this PR adds passes.

No game data used.

**@⁠DaviTostes** on GitHub · 2026-11-24 01:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/182#issuecomment-7119062910) Tested `1827532` under **Wine 11.22 + vkd3d-proton 3.1** on Arch Linux x86_64 (AMD RX 9060 XT, RADV 26.3.1), Windows build with `cargo xwin ... --target x86_64-pc-windows-msvc -p victory-hle` and a native Microsoft `d3dcompiler_47`: **pass**. - `victory_hle`: **86 passed, 1 failed** — the failure is `modules::net::tests::only_loopback_is_reachable` (Wine lacks `WSAConnectByList`, as in #118), not this PR. The test this PR adds passes. No game data used.
Author
Owner

@⁠acetonahard-code on GitHub · 2026-11-24 20:24 UTC · original

Tested on Windows 11 with the repo toolchain, merged into current main (ffe310e):

cargo test -p victory-hle passed failed ignored
main 95 0 0
main + this PR 96 0 0
main, --all-features 95 0 0
main + this PR, --all-features 96 0 0
  • The new test passes.
  • cargo clippy --all-targets -- -D warnings, with and without --all-features: clean.
  • cargo fmt --check: no new diffs from this PR (the ones it reports are already on main).

I didn't test with game data.


Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.

**@⁠acetonahard-code** on GitHub · 2026-11-24 20:24 UTC · [original](https://github.com/Marvisak/VIctory/pull/182#issuecomment-7143513447) Tested on Windows 11 with the repo toolchain, merged into current `main` (ffe310e): | `cargo test -p victory-hle` | passed | failed | ignored | |---|---|---|---| | `main` | 95 | 0 | 0 | | `main` + this PR | 96 | 0 | 0 | | `main`, `--all-features` | 95 | 0 | 0 | | `main` + this PR, `--all-features` | 96 | 0 | 0 | - The new test passes. - `cargo clippy --all-targets -- -D warnings`, with and without `--all-features`: clean. - `cargo fmt --check`: no new diffs from this PR (the ones it reports are already on `main`). I didn't test with game data. --- <sub>Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.</sub>
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:21 UTC · original · edited 2026-11-25 01:15 UTC

Automated triage for the maintainers.

Needs rebase. This pull request conflicts with main (conflicting: crates/victory-hle/src/modules/files.rs). It will be reviewed once it is rebased onto the current main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 00:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/182#issuecomment-7148420194) · edited 2026-11-25 01:15 UTC <!-- victory-triage v1 head=18275322e4d3ea3a36b01b7e91f192e2ad742cdc verdict=needs-rebase at=2026-11-25T01:15:12Z --> Automated triage for the maintainers. **Needs rebase.** This pull request conflicts with `main` (conflicting: `crates/victory-hle/src/modules/files.rs`). It will be reviewed once it is rebased onto the current `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 13:35 UTC · original

Rebased onto current main (63bcca4) so this can move again: commit e466d53 on rebase/182-dotdot-63bcca4. The author is unchanged (Maraco91); only the committer differs.

One conflict, in the test module only: main gained an_empty_root_is_the_current_directory in the same place. Both tests are kept.

Checked on this rebase:

  • cargo test -p victory-hle: 153 passed, 0 failed.
  • cargo clippy -p victory-hle --all-targets -- -D warnings: clean.
  • cargo xtask policy: 192 files ok.

Behaviour, with the call path and the translation table in the test:

Path Host
X:\..\outside.bin via CreateFileW <root>\outside.bin, nothing beside the drive folder
X:\a\.\..\..\..\b\ <root>\b\ — the trailing separator survives
X:\a..b\..c unchanged, dots are names
X:\a\..\b.bin <root>\b.bin, still inside the drive

The trailing-separator case is the one the earlier bundle lost, so it is worth keeping in the table.

If you would rather keep your own branch, cherry-pick e466d53 and force-push; if you want, I can also push it straight onto files/dotdot-stops-at-drive-root when you say it is fine. Git author and a Co-authored-by: andrewpozdnakov7-jpg <[email protected]> trailer if it is folded into another commit.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 13:35 UTC · [original](https://github.com/Marvisak/VIctory/pull/182#issuecomment-7193566471) Rebased onto current `main` (`63bcca4`) so this can move again: commit [e466d53](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/e466d53c8270d6ba63b63c88ae8ca198ceb0ca7f) on [`rebase/182-dotdot-63bcca4`](https://github.com/andrewpozdnakov7-jpg/VIctory/tree/rebase/182-dotdot-63bcca4). The author is unchanged (`Maraco91`); only the committer differs. One conflict, in the test module only: `main` gained `an_empty_root_is_the_current_directory` in the same place. Both tests are kept. Checked on this rebase: - `cargo test -p victory-hle`: 153 passed, 0 failed. - `cargo clippy -p victory-hle --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 192 files ok. Behaviour, with the call path and the translation table in the test: | Path | Host | |---|---| | `X:\..\outside.bin` via `CreateFileW` | `<root>\outside.bin`, nothing beside the drive folder | | `X:\a\.\..\..\..\b\` | `<root>\b\` — the trailing separator survives | | `X:\a..b\..c` | unchanged, dots are names | | `X:\a\..\b.bin` | `<root>\b.bin`, still inside the drive | The trailing-separator case is the one the earlier bundle lost, so it is worth keeping in the table. If you would rather keep your own branch, cherry-pick `e466d53` and force-push; if you want, I can also push it straight onto `files/dotdot-stops-at-drive-root` when you say it is fine. Git author and a `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>` trailer if it is folded into another commit.
This pull request has changes conflicting with the target branch.
  • crates/victory-hle/src/modules/files.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-182'
git switch 'github-bot/gh-182'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-182'
git switch 'github-bot/gh-182'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-182'
git switch 'main'
git merge --squash 'github-bot/gh-182'
git switch 'main'
git merge --ff-only 'github-bot/gh-182'
git switch 'main'
git merge 'github-bot/gh-182'
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!182
No description provided.