Skip to content

Commit 60c6716

Browse files
dschojon-turney
authored andcommitted
Cygwin: symlink_native: allow linking to . again
In 827743a (Cygwin: symlink_native: allow linking to `..`, 2025-06-20), I fixed linking to `..` (which had inadvertently targeted an incorrect location prior to that fix), but inadvertently broke linking to `.` (which would now try to pass the empty string as `lpTargetFileName` to `CreateSymbolicLinkW()`, failing with an `ERROR_INVALID_REPARSE_DATA` which would be surfaced as "Permission denied"). Let's fix this by special-casing an empty string as path as referring to the current directory. Note: It is unclear to me why the `winsymlinks:nativestrict` code path even tries to simplify the symbolic link's target path (e.g. turn an absolute path into a relative one). As long as it refers to a regular Win32 file or directory, I would think that even something like `././c` should have only the slashes converted, not the path simplified (i.e. `.\.\c` instead of `c`). But that's a larger discussion, and I would like to have the bug worked around swiftly. Fixes: 827743a (Cygwin: symlink_native: allow linking to `..`, 2025-06-20) Signed-off-by: Johannes Schindelin <[email protected]>
1 parent d704d04 commit 60c6716

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

winsup/cygwin/path.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,10 @@ symlink_native (const char *oldpath, path_conv &win32_newpath)
18951895
e_old = wcpcpy (e_old, L"..\\"), num--;
18961896
if (num > 0)
18971897
e_old = wcpcpy (e_old, L"..");
1898-
wcpcpy (e_old, c_old);
1898+
if (e_old == final_oldpath->Buffer && c_old[0] == L'\0')
1899+
wcpcpy (e_old, L".");
1900+
else
1901+
wcpcpy (e_old, c_old);
18991902
}
19001903
}
19011904
/* If the symlink target doesn't exist, don't create native symlink.

winsup/cygwin/release/3.6.5

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,5 @@ Fixes:
2929
- Fix multi-thread safety of fork()/exec() by adding the same locking as was
3030
done for spawn.
3131
Addresses: https://cygwin.com/pipermail/cygwin/2025-September/258801.html
32+
33+
- Fix native symlink to '.' (a regresison in 3.6.4)

0 commit comments

Comments
 (0)