summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2023-02-18 12:54:31 -0800
committerEdward Thomson <ethomson@edwardthomson.com>2023-02-18 13:17:44 -0800
commit1be70649432afc0dbac4fdd7d3d50d4881f3c634 (patch)
treef665a976dd37dcd070165b71c2e1eac29af60b45
parent795758d2ada5b4760664050230343920eab528f6 (diff)
downloadlibgit2-1be70649432afc0dbac4fdd7d3d50d4881f3c634.tar.gz
repo: don't fail on strange win32 paths
With some paths on Win32, we cannot identify the owner because it's on a file share (WSL2 or UNC). In that case, don't fail, but identify that the current user does not own the path. This matches Git for Windows behavior.
-rw-r--r--src/libgit2/repository.c3
-rw-r--r--src/util/fs_path.c2
2 files changed, 4 insertions, 1 deletions
diff --git a/src/libgit2/repository.c b/src/libgit2/repository.c
index 489d627a0..c02662bda 100644
--- a/src/libgit2/repository.c
+++ b/src/libgit2/repository.c
@@ -547,6 +547,9 @@ static int validate_ownership_path(bool *is_safe, const char *path)
if (error == GIT_ENOTFOUND) {
*is_safe = true;
error = 0;
+ } else if (error == GIT_EINVALID) {
+ *is_safe = false;
+ error = 0;
}
return error;
diff --git a/src/util/fs_path.c b/src/util/fs_path.c
index 6c87bfd01..b52867e77 100644
--- a/src/util/fs_path.c
+++ b/src/util/fs_path.c
@@ -1855,7 +1855,7 @@ static int file_owner_sid(PSID *out, const char *path)
PSECURITY_DESCRIPTOR descriptor = NULL;
PSID owner_sid;
DWORD ret;
- int error = -1;
+ int error = GIT_EINVALID;
if (git_win32_path_from_utf8(path_w32, path) < 0)
return -1;