summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c8b2964)
raw | patch | inline | side by side (parent: c8b2964)
author | Clemens Buchacher <drizzd@aon.at> | |
Sat, 22 May 2010 12:21:27 +0000 (14:21 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 25 May 2010 16:28:51 +0000 (09:28 -0700) |
If we are in a git directory, get_git_work_tree() can return NULL.
While trying to determine whether or not the given paths are outside
the work tree, the following command would read from it anyways and
trigger a segmentation fault.
git diff / /
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
While trying to determine whether or not the given paths are outside
the work tree, the following command would read from it anyways and
trigger a segmentation fault.
git diff / /
Signed-off-by: Clemens Buchacher <drizzd@aon.at>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff-no-index.c | patch | blob | history |
diff --git a/diff-no-index.c b/diff-no-index.c
index aae8e7accc1ff955bd76c62b379b37f343f61cc4..4cd9dacbe8e98d1420ebe1a217b0f927d24d125a 100644 (file)
--- a/diff-no-index.c
+++ b/diff-no-index.c
static int path_outside_repo(const char *path)
{
- /*
- * We have already done setup_git_directory_gently() so we
- * know we are inside a git work tree already.
- */
const char *work_tree;
size_t len;
if (!is_absolute_path(path))
return 0;
work_tree = get_git_work_tree();
+ if (!work_tree)
+ return 1;
len = strlen(work_tree);
if (strncmp(path, work_tree, len) ||
(path[len] != '\0' && path[len] != '/'))