Skip to content

fix(native_path): preserve literal trailing '.'/' ' components in to_extended_path - #1293

Merged
caomengxuan666 merged 1 commit into
mainfrom
fix/1283-trailing-dot-operands
Oct 25, 2026
Merged

caomengxuan666 merged 1 commit into
mainfrom
fix/1283-trailing-dot-operands

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Fixes #1283

Summary

PR #1285 (merged) fixed the find hard-crash half: the walk now probes/iterates through \\?\ extended paths, so both repros below no longer crash on a fresh master build. Residual: an operand spelling that names a trailing-dot/space entry still resolved to the wrong object because to_extended_path absolutizes via GetFullPathNameW, which strips a trailing . or from every component (D:\x\inner. → D:\x\inner → ENOENT). find, ls, stat, cat all reported "No such file or directory" for entries that exist — while MSYS resolves them.

This PR absolutizes lexically when any component ends in ./ (and is not ./..): resolves the root form (UNC share, X:\ absolute, X: drive-relative via its own cwd, \ cwd-rooted, plain relative via cwd), folds ./.., and keeps every other component verbatim so the \\?\ result reaches the same literal name MSYS opens. All other spellings keep the existing GetFullPathNameW path.

Verified on the fresh build

Before (master @628cdd8):

find D:\tmp\wc-audit\x\inner.   -> find: 'D:/.../inner.': No such file or directory (exit 1)
find inner./                  -> find: 'inner./': No such file or directory (exit 1)
cat inner.\f.txt              -> No such file or directory (exit 1)
ls  zz.                       -> cannot access 'zz.': No such file or directory (exit 2)

After:

find inner./   -> inner. / inner./f.txt   (exit 0)
find inner.    -> inner. / inner./f.txt   (exit 0)
cat inner.\f.txt -> hi                    (exit 0)
ls zz. / stat 'tt '                        (exit 0)

mkdir D:\x\NUL now refuses cleanly (exit 1), matching the issue's "refuse creation" resolution; mkdir existing/mkdir -v/rm -v/D:name findings verified already fixed on master.

Test plan

  • New regression test find.find_trailing_dot_root_resolves_literal_name creates a real inner. dir via \\?\ and asserts find inner./ + find inner. enumerate it
  • winuxcmd-tests --run-test find: 120/120 pass; sweep of find/ls/stat/mkdir/rmdir/rm/realpath/cat/touch/cp/mv: 508 tests, only failure was the pre-existing broken test-write helper (fixed in this test)
  • scripts/format.py clean

Generated with Devin

…extended_path (#1283)

GetFullPathNameW strips a trailing dot or space from every component, so
an operand naming an on-disk "inner." or "tt " entry absolutized onto a
different (usually missing) name and every probe reported ENOENT. When
such a component is present, absolutize lexically instead: resolve the
root form (UNC share, drive-absolute, drive-relative, cwd-relative),
fold "." and "..", and keep every other component verbatim so the \\?\
result reaches the same literal name MSYS opens.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

find hard-crashes (0xC0000409) on trailing-dot dirs and >MAX_PATH recursion; 'D:name' operand resolves 3 different ways across applets

1 participant