]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-blame: prevent argument parsing segfault
authorTommi Kyntola <tommi.kyntola@ray.fi>
Fri, 16 Feb 2007 08:50:58 +0000 (10:50 +0200)
committerJunio C Hamano <junkio@cox.net>
Sat, 17 Feb 2007 05:39:21 +0000 (21:39 -0800)
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 <tommi.kyntola@ray.fi>
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-blame.c

index 69fc145a38090488e8da4b60a56154fc999b6fe5..1a752b95bb32578cd3ecb69153b55f605b8bfdc3 100644 (file)
@@ -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];