]> Pileus Git - ~andy/git/commitdiff
setup_git_directory_gently: fix off-by-one error
authorMatthias Lederhofer <matled@gmx.net>
Sun, 11 Mar 2007 01:35:00 +0000 (02:35 +0100)
committerJunio C Hamano <junkio@cox.net>
Sun, 11 Mar 2007 05:47:45 +0000 (21:47 -0800)
don't tell getcwd that the buffer has one spare byte for an extra /

Signed-off-by: Matthias Lederhofer <matled@gmx.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
setup.c

diff --git a/setup.c b/setup.c
index e9d3f5aab63225df7f1b495a19740408d23973a8..76e5e693ccfbdcdcc763405ae026916902be830e 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -216,7 +216,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
                die("Not a git repository: '%s'", gitdirenv);
        }
 
-       if (!getcwd(cwd, sizeof(cwd)) || cwd[0] != '/')
+       if (!getcwd(cwd, sizeof(cwd)-1) || cwd[0] != '/')
                die("Unable to read current working directory");
 
        offset = len = strlen(cwd);