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

Open
Maraco91 wants to merge 1 commit from upstream-pr/182 into main
Maraco91 commented 2026-11-24 01:12:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Maraco91 on 2026-11-24T01:12:45Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:issue:6572328679 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/182). Originally posted by [Maraco91](https://github.com/Maraco91) on 2026-11-24T01:12:45Z. --- ## 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)
DaviTostes commented 2026-11-24 06:54:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T01:24:04Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7119062910 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/182#issuecomment-7119062910). Originally posted by [DaviTostes](https://github.com/DaviTostes) on 2026-11-24T01:24:04Z. --- 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.
acetonahard-code commented 2026-11-24 21:03:29 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by acetonahard-code on 2026-11-24T20:24:59Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7143513447 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/182#issuecomment-7143513447). Originally posted by [acetonahard-code](https://github.com/acetonahard-code) on 2026-11-24T20:24:59Z. --- 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>
Marvisak commented 2026-11-25 01:07:41 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:21:14Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148420194 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/182#issuecomment-7148420194). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:21:14Z. --- <!-- 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)_
andrewpozdnakov7-jpg commented 2026-11-26 14:01:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T13:35:38Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7193566471 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/182#issuecomment-7193566471). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T13:35:38Z. --- 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 cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/182:upstream-pr/182'
git switch 'upstream-pr/182'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/182'
git switch 'upstream-pr/182'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/182'
git switch 'upstream-pr/182'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/182'
git switch 'main'
git merge --squash 'upstream-pr/182'
git switch 'main'
git merge --ff-only 'upstream-pr/182'
git switch 'main'
git merge 'upstream-pr/182'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
Marvisak/VIctory!182
No description provided.