summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2020-01-12 10:12:57 +0000
committerGitHub <noreply@github.com>2020-01-12 10:12:57 +0000
commitcc4f4cbea48ac00a5edec1b3570ac3d2ef10fe77 (patch)
tree4cbdf1209cd23daf74e21c3d02edff09ee46827a /src
parentd5482339ff58f74d44f46a3e20a354b810f616c1 (diff)
parent7d55bee6d19a20b73c5f6cbeb7f4debc45bd76e9 (diff)
downloadlibgit2-cc4f4cbea48ac00a5edec1b3570ac3d2ef10fe77.tar.gz
Merge pull request #5355 from pks-t/pks/win32-relative-symlink-across-dirs
win32: fix relative symlinks pointing into dirs
Diffstat (limited to 'src')
-rw-r--r--src/win32/posix_w32.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/win32/posix_w32.c b/src/win32/posix_w32.c
index 2bc93a3c7..29641bdaf 100644
--- a/src/win32/posix_w32.c
+++ b/src/win32/posix_w32.c
@@ -439,8 +439,16 @@ int p_symlink(const char *target, const char *path)
git_win32_path target_w, path_w;
DWORD dwFlags;
+ /*
+ * Convert both target and path to Windows-style paths. Note that we do
+ * not want to use `git_win32_path_from_utf8` for converting the target,
+ * as that function will automatically pre-pend the current working
+ * directory in case the path is not absolute. As Git will instead use
+ * relative symlinks, this is not someting we want.
+ */
if (git_win32_path_from_utf8(path_w, path) < 0 ||
- git__utf8_to_16(target_w, MAX_PATH, target) < 0)
+ git__utf8_to_16(target_w, MAX_PATH, target) < 0 ||
+ git_win32_path_canonicalize(target_w) < 0)
return -1;
dwFlags = SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE;