git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] test get_git_work_tree() return value for NULL
@ 2010-05-22 12:21 Clemens Buchacher
  2010-05-26  5:07 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Clemens Buchacher @ 2010-05-22 12:21 UTC (permalink / raw
  To: Junio C Hamano; +Cc: git

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>
---
 diff-no-index.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/diff-no-index.c b/diff-no-index.c
index aae8e7a..4cd9dac 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -150,16 +150,14 @@ static int queue_diff(struct diff_options *o,
 
 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] != '/'))
-- 
1.7.0.5.3.ga76e

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] test get_git_work_tree() return value for NULL
  2010-05-22 12:21 [PATCH] test get_git_work_tree() return value for NULL Clemens Buchacher
@ 2010-05-26  5:07 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2010-05-26  5:07 UTC (permalink / raw
  To: Clemens Buchacher; +Cc: git

Thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-05-26  5:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-22 12:21 [PATCH] test get_git_work_tree() return value for NULL Clemens Buchacher
2010-05-26  5:07 ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).