HLE/files: a title path's ".." stops at the mounted drive's root #1444

Open
CwWwWwW wants to merge 1 commit from upstream-pr/1444 into main
CwWwWwW commented 2026-11-27 08:39:21 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by CwWwWwW on 2026-11-27T08:39:21Z.


Problem

The victory-hle files module maps a host folder to a virtual drive and rewrites the title's path onto it (translate). For a short path the title's tail is appended to the mount's host folder unchanged, and the host's own path clean-up then resolves .. against the host volume's root, not against the mount root. A title path with more .. than its depth therefore leaves the folder the drive stands for: X:\..\..\save.bin is written beside the mount instead of at its root, where the title will not find it again (and another folder of the host can be hit).

The console clamps .. at the drive's root, and this layer's own \\?\ branch for long paths (verbatim) already does that, so the short branch contradicted both.

Fix

Resolve . and .. in the title's tail with the mount root as the floor, and only when the path names such a component: every other path keeps its exact form and the host's clean-up. X: and X:name stay relative to the root, a trailing separator is kept, and the \\?\-prefixed form gets the same treatment.

Regression test

files::tests::dots_stop_at_the_mounted_root mounts a temp folder as a drive and checks that X:\a\..\..\b.txt resolves inside the mount, then writes through X:\..\escaped.bin: with the old code the file is created beside the mount root (the test fails: left ...\storage\a\..\..\b.txt) and with the change it stays in the folder.

Verification

  • cargo test -p victory-hle --lib --locked: 104 passed, 0 failed
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings: clean
  • one file changed: crates/victory-hle/src/modules/files.rs (+78)

Found and fixed independently in this tree; no external code was used.

The PR's Clippy check fails on main already: at 9a9091d cargo clippy --workspace --all-targets fails in victory-shader (wave64_after_loop.rs precedence, valu_tests.rs simplifiable/negated partial-ord comparisons); open PR #1440 fixes exactly those lints. This diff touches none of those files, and the touched crate's own tests and clippy are clean locally.

<!-- greyfinch-sync:fxceless/victory-fork:issue:5523688503 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/1444). Originally posted by [CwWwWwW](https://github.com/CwWwWwW) on 2026-11-27T08:39:21Z. --- ## Problem The `victory-hle` `files` module maps a host folder to a virtual drive and rewrites the title's path onto it (`translate`). For a short path the title's tail is appended to the mount's host folder unchanged, and the host's own path clean-up then resolves `..` against the **host volume's root**, not against the mount root. A title path with more `..` than its depth therefore leaves the folder the drive stands for: `X:\..\..\save.bin` is written beside the mount instead of at its root, where the title will not find it again (and another folder of the host can be hit). The console clamps `..` at the drive's root, and this layer's own `\\?\` branch for long paths (`verbatim`) already does that, so the short branch contradicted both. ## Fix Resolve `.` and `..` in the title's tail with the mount root as the floor, and only when the path names such a component: every other path keeps its exact form and the host's clean-up. `X:` and `X:name` stay relative to the root, a trailing separator is kept, and the `\\?\`-prefixed form gets the same treatment. ## Regression test `files::tests::dots_stop_at_the_mounted_root` mounts a temp folder as a drive and checks that `X:\a\..\..\b.txt` resolves inside the mount, then writes through `X:\..\escaped.bin`: with the old code the file is created beside the mount root (the test fails: left `...\storage\a\..\..\b.txt`) and with the change it stays in the folder. ## Verification - `cargo test -p victory-hle --lib --locked`: 104 passed, 0 failed - `cargo clippy -p victory-hle --all-targets --locked -- -D warnings`: clean - one file changed: `crates/victory-hle/src/modules/files.rs` (+78) Found and fixed independently in this tree; no external code was used. The PR's Clippy check fails on main already: at 9a9091d `cargo clippy --workspace --all-targets` fails in `victory-shader` (wave64_after_loop.rs precedence, valu_tests.rs simplifiable/negated partial-ord comparisons); open PR #1440 fixes exactly those lints. This diff touches none of those files, and the touched crate's own tests and clippy are clean locally.
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/1444:upstream-pr/1444'
git switch 'upstream-pr/1444'

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/1444'
git switch 'upstream-pr/1444'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1444'
git switch 'upstream-pr/1444'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1444'
git switch 'main'
git merge --squash 'upstream-pr/1444'
git switch 'main'
git merge --ff-only 'upstream-pr/1444'
git switch 'main'
git merge 'upstream-pr/1444'
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
fxceless/victory-fork!1444
No description provided.