diff options
author | Brian Gernhardt <benji@silverinsanity.com> | 2006-12-22 08:56:25 -0500 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-12-22 23:17:20 -0800 |
commit | c321f00d09f56dcf2f149757a2a337f3732f3097 (patch) | |
tree | 8c510e21b9456ddb49d054490705ba4e895b47fa /git.c | |
parent | 4b1552238ec3b8b711f60b2b65265a751a40f5ff (diff) | |
download | git-c321f00d09f56dcf2f149757a2a337f3732f3097.tar.gz |
Keep "git --git-dir" from causing a bus error.
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>
Diffstat (limited to 'git.c')
-rw-r--r-- | git.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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)--; |