From f44213258de3fbef932f9c655213202f69dccc80 Mon Sep 17 00:00:00 2001 From: Tommi Kyntola Date: Fri, 16 Feb 2007 10:50:58 +0200 Subject: [PATCH] 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 --- builtin-blame.c | 3 +++ 1 file changed, 3 insertions(+) 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]; -- 2.26.2