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

Manually merged
github merged 1 commit from github-bot/gh-835 into main 2026-11-29 08:22:28 +00:00 AGit
Owner

@⁠CwWwWwW on GitHub · 2026-11-28 07:34 UTC · original
CwWwWwW:fix/mount-root-dot-clamp → main · +78 −0 · 1 files · 1 commits · merged 2026-11-29 08:16 UTC

Ported to trustno1-coder/VIctory-NVIDIA from the same change submitted to fxceless/victory-fork as PR #1444 (head 719d8ee928, author CwWwWwW). The fork's own line was dropped when it rebased onto 959dcaf (5dbf5ce), so this is submitted here directly. The description below is the original one; its 'Verification' numbers refer to the fork tree. Rebased onto main 63b902f.

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.

Verification on this tree (base 63b902f, 2026-11-27)

  • cargo check --workspace --all-targets --locked: pass (Rust 1.98.1, the version pinned in rust-toolchain.toml)
  • cargo check --workspace --all-targets --all-features --locked: pass
  • cargo clippy --workspace --all-targets --locked -- -D warnings (and --all-features): this change adds no clippy finding. The only failures are on unmodified lines of main (clippy::manual_is_multiple_of at crates/victory-gpu/src/shadow.rs:1708 and crates/victory-gpu/src/descriptor.rs:1234, clippy::let_and_return at crates/victory-shader/src/emit/mod.rs:2768); CI run 46104876336 on 63b902f failed on those before this change.
  • cargo test was not run in the author's environment (Windows VM without an MSVC toolchain; test binaries could not be linked there). CI on Windows and a run on the card should confirm.
**@⁠CwWwWwW** on GitHub · 2026-11-28 07:34 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/835) `CwWwWwW:fix/mount-root-dot-clamp` → `main` · +78 −0 · 1 files · 1 commits · merged 2026-11-29 08:16 UTC Ported to trustno1-coder/VIctory-NVIDIA from the same change submitted to fxceless/victory-fork as PR #1444 (head 719d8ee9288c8910031e08d051bebc4fe8977e42, author CwWwWwW). The fork's own line was dropped when it rebased onto 959dcaf (5dbf5ce), so this is submitted here directly. The description below is the original one; its 'Verification' numbers refer to the fork tree. Rebased onto main 63b902f. ## 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. ## Verification on this tree (base 63b902f, 2026-11-27) - cargo check --workspace --all-targets --locked: pass (Rust 1.98.1, the version pinned in rust-toolchain.toml) - cargo check --workspace --all-targets --all-features --locked: pass - cargo clippy --workspace --all-targets --locked -- -D warnings (and --all-features): this change adds no clippy finding. The only failures are on unmodified lines of main (clippy::manual_is_multiple_of at crates/victory-gpu/src/shadow.rs:1708 and crates/victory-gpu/src/descriptor.rs:1234, clippy::let_and_return at crates/victory-shader/src/emit/mod.rs:2768); CI run 46104876336 on 63b902f failed on those before this change. - cargo test was not run in the author's environment (Windows VM without an MSVC toolchain; test binaries could not be linked there). CI on Windows and a run on the card should confirm.
The short-path branch of translate() appended the title tail to the mount folder and let the host resolve ".." against the host volume root: a title path with enough ".." left the folder the drive stands for. Resolve "." and ".." in the tail with the mount root as the floor (the same clamp the verbatim branch already did), only when the path names such a component.

Regression test: files::tests::dots_stop_at_the_mounted_root.

Ported from fxceless/victory-fork PR #1444 (head 4763afe400355e833d8194ee5e7c6effa4bf8a2a).
Original author: CwWwWwW <[email protected]>.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-28 14:28:36 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-28 07:49 UTC · original · approved these changes

Tested locally merged onto main (63b902f).

  • Merge & Policy: Clean merge; cargo xtask policy passed (294 files ok).
  • Tests: cargo test -p victory-hle --lib files passed (10 passed; 0 failed, including the new dots_stop_at_the_mounted_root test) with 0 compiler warnings.

Important path-normalization/containment fix ensuring .. segments cannot escape the mounted drive root. LGTM.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

**@⁠Dukestar69** on GitHub · 2026-11-28 07:49 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/835#pullrequestreview-6096619244) · **approved these changes** Tested locally merged onto `main` (`63b902f`). - **Merge & Policy**: Clean merge; `cargo xtask policy` passed (`294 files ok`). - **Tests**: `cargo test -p victory-hle --lib files` passed (`10 passed; 0 failed`, including the new `dots_stop_at_the_mounted_root` test) with 0 compiler warnings. Important path-normalization/containment fix ensuring `..` segments cannot escape the mounted drive root. LGTM. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
github manually merged commit 7a88bfccf5 into main 2026-11-29 08:22:28 +00:00
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/trustno1-coder--VIctory-NVIDIA!835
No description provided.