Skip to content

On-disk directory named NUL is undeletable: rm -rf resolves the operand to the device and reports false success #1297

Closed

Description

@caomengxuan666

Summary

A real on-disk directory named NUL can be created but is afterwards undeletable through WinuxCmd: every applet resolves the operand NUL to the DOS device, so rm -rf exits 0 while the directory stays on disk (false success). MSYS rm -rf removes it.

Repro (cmd.exe, from the original audit)

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 disk

mkdir NUL itself mirrors MSYS (also creates the real dir — fine), but afterwards ls/cd/rm -rf all act on the device and rm -rf reports success while the directory persists. Either refuse creation like the device namespace implies, or route removal through \\?\ so the entry is not stranded.

Provenance

Split out of #1283, whose bundled path/name audit listed this as finding 4. It is a defect independent of #1283's title subjects (find crash + D:name resolution, fixed in the winx cluster / PR for #1283). The winx cluster registered it as an observation only and did not independently re-verify it; the repro above is the original report's.

Metadata

Metadata

Labels

bugcompat-gap

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions