summaryrefslogtreecommitdiff
path: root/setup.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2019-08-24 22:10:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-08-26 17:03:41 (GMT)
commit5cf7b3b1acf2e603d92132906bc6929141172d4c (patch)
tree62e52960f4bd40fe12b7d8a5ebb431d951bcf29f /setup.c
parente2683d51d96f5e95489d29ee6dfafdde790579e4 (diff)
downloadgit-5cf7b3b1acf2e603d92132906bc6929141172d4c.zip
git-5cf7b3b1acf2e603d92132906bc6929141172d4c.tar.gz
git-5cf7b3b1acf2e603d92132906bc6929141172d4c.tar.bz2
setup_git_directory(): handle UNC root paths correctly
When working in the root directory of a file share (this is only possible in Git Bash and Powershell, but not in CMD), the current directory is reported without a trailing slash. This is different from Unix and standard Windows directories: both / and C:\ are reported with a trailing slash as current directories. If a Git worktree is located there, Git is not quite prepared for that: while it does manage to find the .git directory/file, it returns as length of the top-level directory's path *one more* than the length of the current directory, and setup_git_directory_gently() would then return an undefined string as prefix. In practice, this undefined string usually points to NUL bytes, and does not cause much harm. Under rare circumstances that are really involved to reproduce (and not reliably so), the reported prefix could be a suffix string of Git's exec path, though. A careful analysis determined that this bug is unlikely to be exploitable, therefore we mark this as a regular bug fix. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/setup.c b/setup.c
index a0cb42c..03efbb2 100644
--- a/setup.c
+++ b/setup.c
@@ -797,7 +797,7 @@ static const char *setup_discovered_git_dir(const char *gitdir,
set_git_dir(gitdir);
inside_git_dir = 0;
inside_work_tree = 1;
- if (offset == cwd->len)
+ if (offset >= cwd->len)
return NULL;
/* Make "offset" point past the '/' (already the case for root dirs) */