Skip to content

Commit

Permalink
Keep "git --git-dir" from causing a bus error.
Browse files Browse the repository at this point in the history
The option checking code for --git-dir had an off by 1 error that
would cause it to access uninitialized memory if it was the last
argument.  This causes it to display an error and display the usage
string instead.

Signed-off-by: Brian Gernhardt <benji@silverinsanity.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Brian Gernhardt authored and Junio C Hamano committed Dec 23, 2006
1 parent 4b15522 commit c321f00
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions git.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ static int handle_options(const char*** argv, int* argc)
} else if (!strcmp(cmd, "-p") || !strcmp(cmd, "--paginate")) {
setup_pager();
} else if (!strcmp(cmd, "--git-dir")) {
if (*argc < 1)
return -1;
if (*argc < 2) {
fprintf(stderr, "No directory given for --git-dir.\n" );
usage(git_usage_string);
}
setenv("GIT_DIR", (*argv)[1], 1);
(*argv)++;
(*argc)--;
Expand Down

0 comments on commit c321f00

Please sign in to comment.