From: Tommi Kyntola Date: Fri, 16 Feb 2007 08:50:58 +0000 (+0200) Subject: git-blame: prevent argument parsing segfault X-Git-Tag: v1.5.0.1~8 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f44213258de3fbef932f9c655213202f69dccc80;p=git.git git-blame: prevent argument parsing segfault The 3rd branch in builtin-blame.c should also check for lacking arguments. Running that in top dir does not trigger the problem because the 'prefix' is NULL. Signed-off-by: Tommi Kyntola Signed-off-by: Junio C Hamano --- diff --git a/builtin-blame.c b/builtin-blame.c index 69fc145a3..1a752b95b 100644 --- a/builtin-blame.c +++ b/builtin-blame.c @@ -2200,6 +2200,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix) if (!strcmp(argv[j], "--")) seen_dashdash = j; if (seen_dashdash) { + /* (2) */ if (seen_dashdash + 1 != argc - 1) usage(blame_usage); path = add_prefix(prefix, argv[seen_dashdash + 1]); @@ -2208,6 +2209,8 @@ int cmd_blame(int argc, const char **argv, const char *prefix) } else { /* (3) */ + if (argc <= i) + usage(blame_usage); path = add_prefix(prefix, argv[i]); if (i + 1 == argc - 1) { final_commit_name = argv[i + 1];