Skip to content

Windows junction_point leaves empty directory when reparse setup fails #548

Description

@SebTardif

Bug

library/std/src/sys/fs/windows.rs junction_point creates a real directory (create_new) before FSCTL_SET_REPARSE_POINT. On path-conversion failure or DeviceIoControl failure, it returns Err but does not remove the empty directory. Callers retrying get AlreadyExists; the path is not a junction.

Combined with #263 (uninit substitute-name NUL in the reparse buffer), failed creates are more likely.

Impact

Orphan empty directories; broken retry behavior; non-junction path left behind.

Origin

Lines Commit Date Author
1636-1712 (create-then-reparse, no rollback) d6945f6d8c1 2025-07-17 ltdk

Suggested fix

On error after create: drop the handle, best-effort RemoveDirectoryW/rmdir on link. Also write the substitute-name terminating NUL (#263).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-libsStandard libraryI-wrongWrong result or data corruptionO-windowsWindows-specificP-mediumMedium impact: affects specific usage patternsbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions