summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2021-04-15 01:23:07 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2021-04-28 13:03:34 +0100
commit717df1a4d201e713d8e16aae1d258d9cc27a86dc (patch)
tree49b8b8bc3f305683998166422f6d86f48b6e4e9f
parentf3bcadd2bb87337aeca961d37e153c54cbecfadd (diff)
downloadlibgit2-717df1a4d201e713d8e16aae1d258d9cc27a86dc.tar.gz
worktree: validate worktree paths
Worktree paths need to fix within MAX_PATH always, regardless of `core.longpaths` setting.
-rw-r--r--src/worktree.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/worktree.c b/src/worktree.c
index 7d447e896..0bced6d4a 100644
--- a/src/worktree.c
+++ b/src/worktree.c
@@ -135,6 +135,9 @@ static int open_worktree_dir(git_worktree **out, const char *parent, const char
goto out;
}
+ if ((error = git_path_validate_workdir(NULL, dir)) < 0)
+ goto out;
+
if ((wt = git__calloc(1, sizeof(*wt))) == NULL) {
error = -1;
goto out;
@@ -264,14 +267,14 @@ int git_worktree_validate(const git_worktree *wt)
wt->commondir_path);
return GIT_ERROR;
}
-
+
if (!git_path_exists(wt->worktree_path)) {
git_error_set(GIT_ERROR_WORKTREE,
"worktree directory '%s' does not exist",
wt->worktree_path);
return GIT_ERROR;
}
-
+
return 0;
}