Skip to content

Commit

Permalink
setup_git_directory_gently: fix off-by-one error
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Matthias Lederhofer authored and Junio C Hamano committed Mar 11, 2007
1 parent 8bb2b51 commit 96a5702
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 96a5702

Please sign in to comment.