Repository navigation
Description
Environment
niu --version: Niubash 1.4.4 / rubash git fa64d58dfb9c / WinuxCmd 1.1.17- Windows 10.0.19045, invoked via
winuxcmd.exeapplets andniushell builtins - Oracle where ambiguous: MSYS Git Bash (
D:\Git\usr\bin)
Path/name edge audit across the applet surface (UNC, drive-relative, reserved names, real trailing ./ names, >MAX_PATH, Unicode). Four real defects plus a verbose-flag gap; everything else checked was clean (coverage list at bottom).
Findings table
| # | Defect | Severity | Repro |
|---|---|---|---|
| 1 | find crashes STATUS_STACK_BUFFER_OVERRUN (exit -1073740791 / 0xC0000409) when it encounters a directory ending in ., and when recursion crosses ~260 chars |
High | below |
| 2 | D:name operand resolves three different ways: touch/realpath = drive-relative, cat + niu > redirect = PUA literal D<U+F03A>name, stat/mv/head/tail/grep = ENOENT |
Medium | below |
| 3 | mkdir existing_dir exits 0 silently — GNU/MSYS print mkdir: cannot create directory 'x': File exists and exit 1 |
Medium | one-liner |
| 4 | rm -rf NUL on a real on-disk dir named NUL exits 0 but leaves it — every applet resolves the operand to the device, so the dir is undeletable via WinuxCmd |
Medium | below |
| 5 | -v/--verbose silently ignored by rm, mkdir, rmdir (while cp/mv/install print correctly) |
Low | one-liner |
1. find crash — STATUS_STACK_BUFFER_OVERRUN
find is the only applet that crashes; ls -R, stat, cat, touch, du, grep -r all cope (they presumably take the \\?\ path). Nothing on stderr; process fast-fails.
Repro A — directory whose name ends in . (cmd.exe):
:: create a real NTFS dir literally named "inner." (Git Bash ships with Windows Git):
D:\Git\usr\bin\mkdir.exe -p D:\x\inner.
D:\Git\usr\bin\bash.exe -c "echo hi > D:/x/inner./f.txt"
C:\Users\cmx\AppData\Local\Programs\Niubash\winuxcmd\usr\bin\winuxcmd.exe find D:\xActual:
D:/x
D:/x/inner.
<process aborts; exit code -1073740791 = 0xC0000409>
Expected (MSYS find.exe on identical tree):
D:\x
D:\x/inner.
D:\x/inner./f.txt
Also crashes at -maxdepth 1, so find opens the entry even when it won't descend — looks like an unhandled failure in the directory-open path rather than depth handling. A file named trail (trailing space) does not trigger it — only .-terminated directory names observed so far.
Repro B — recursion past ~256–260 chars (fully cmd.exe-invocable):
C:\...\winuxcmd.exe mkdir -p D:\tmp\mkdeep\ddddddddddddddddddddddd\ddddddddddddddddddddddd\ddddddddddddddddddddddd\ddddddddddddddddddddddd\ddddddddddddddddddddddd\ddddddddddddddddddddddd\ddddddddddddddddddddddd\ddddddddddddddddddddddd\ddddddddddddddddddddddd\ddddddddddddddddddddddd\ddddddddddddddddddddddd\ddddddddddddddddddddddd\ddddddddddddddddddddddd
C:\...\winuxcmd.exe find D:\tmp\mkdeepActual: prints levels until the path hits ~261 chars, then aborts 0xC0000409. winuxcmd ls -R D:\tmp\mkdeep on the same tree completes fine (exit 0). Same crash via UNC: winuxcmd find //localhost/c$/... — I hit this in the wild scanning C:\Users\cmx\AppData\Local\Temp, where leftover dirs (niu-path-audit\deep\…, vt\inner.) kill find both on the drive path and on \\localhost\c$.
(Sibling of closed #1061 — same missing \\?\/long-path plumbing, but find crashes instead of failing gracefully, so reporting separately.)
2. D:name (drive-relative-shaped operand) — three divergent resolutions
On GNU/POSIX D:name is an ordinary relative filename (: is legal). MSYS agrees and stores it via private-use escaping. WinuxCmd splits three ways:
| Applet | Interpretation | Result for D:wux.txt in D:\tmp\pa |
|---|---|---|
winuxcmd touch D:wux.txt |
drive-relative | creates D:\tmp\pa\wux.txt |
winuxcmd cat D:wux.txt |
PUA literal | reads file D<U+F03A>wux.txt |
winuxcmd stat / mv / head / tail / grep |
none | ENOENT |
winuxcmd realpath D:wux.txt |
drive-relative | prints D:\tmp\pa\wux.txt even when only the PUA file exists |
Concrete: after niu redirect echo x > 'D:driverel_test.txt' creates D<U+F03A>driverel_test.txt (PUA literal — matches MSYS), winuxcmd cat 'D:driverel_test.txt' reads it, but winuxcmd stat 'D:driverel_test.txt' → cannot statx … No such file or directory, and winuxcmd touch 'D:newfile2.txt' creates newfile2.txt (drops D:). Pick one interpretation and apply it uniformly; the PUA literal is the POSIX-faithful one.
The > redirect create-side lives in the engine — filed as unixwin/rubash#NNN (cross-link).
3. mkdir on existing dir — silent success
winuxcmd.exe mkdir D:\tmp\pa & winuxcmd.exe mkdir D:\tmp\pa & echo %errorlevel%Actual: exit 0, no output, both runs.
GNU/MSYS: mkdir: cannot create directory 'D:\tmp\pa': File exists, exit 1. (mkdir -p correctly idempotent.)
4. Reserved-name dir created but undeletable / false rm success
winuxcmd.exe mkdir D:\tmp\pa\NUL :: exits 0, creates a REAL on-disk dir named NUL
winuxcmd.exe rm -rf D:\tmp\pa\NUL :: exits 0 …
winuxcmd.exe ls D:\tmp\pa\NUL :: shows the NUL *device* (crw-), dir still on diskmkdir NUL itself mirrors MSYS (also creates the real dir — fine), but afterwards every WinuxCmd op resolves NUL to the device: ls/cd/rm -rf all act on the device and rm -rf reports success while the directory persists. MSYS rm -rf removes it. Either refuse creation like the device namespace implies, or route removal through \\?\ so it doesn't strand the entry.
5. -v ignored by rm/mkdir/rmdir
cp -v, mv -v, install -v print 'a' -> 'b' correctly; rm -v f, mkdir -v d, rmdir -v d exit 0 with no output. GNU prints removed 'f' / mkdir: created directory 'd'.
Coverage — checked CLEAN
- UNC
\\localhost\c$+//localhost/c$/dialects:ls,cp↔local,cat,grep,du,df(share root too),tee,mv,rm,touch,mkdir,sort,findon normal trees — all OK. - Mixed dialects in one operand list (
cp /d/x C:\y, forward+backslash+/d/forms): all resolve. - Unicode names: CJK
文件.txt, emojiemoji_🎉_test.txt, combiningé:ls, glob,stat,cat,find,sort,lnhardlink — all OK. - Case-insensitive resolution (
cat FOOBAR.TXTonFooBar.txt,rmwrong case): OK; glob passthrough on no-match correct. - Trailing
./names on create are normalized away (mkdir 'd.'→d) — matches Windows/MSYS. ls,stat,touch,cat,tee,ls -Ron 261+ char paths: OK (findis the lone crasher).rm -rfon a dir containinginner.: removes cleanly.- Device-name writes (
echo > path\NUL) discard to the device — Windows semantics, OK. readlink -m/realpathon UNC and..\paths: OK.ln -sEPERM is privilege, not a bug.cd/>/redirection on all UNC + mixed forms: OK except theD:nameredirect above andcdinto >260-char dir →ENAMETOOLONG(Win32SetCurrentDirectorylimit — noted, likely platform-bound).
Generated with Devin
Activity
caomengxuan666 commentedon Oct 22, 2026
Engine-side half of finding #2 (
> 'D:name'redirect creates the PUA-escaped literal) is filed as unixwin/rubash#1183.Merge pull request #1299 from unixwin/fix/winx
fix(native_path): do not let GetFullPathNameW collapse device-named l…
fix(tests): absolutize literal dot/space fixture names lexically in T…
rust2(canon): port the resolver operand folds (#1231/#1246/#1283) (#1488
feat(winux-core): port the shell-namespace path contract from 1.x nat…
feat(winux-core): port the shell-namespace path contract from 1.x nat…
feat(a1): replay preserve-root closure + chmod/chgrp/chown tr! on main (