threads / patch / 6841

patchgit-blame: prevent argument parsing segfault

Subject: [PATCH] git-blame: prevent argument parsing segfault

## tl;dr

2 messages between Feb 16, 2007 and Feb 16, 2007. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Tommi Kyntola· Feb 16, 2007, 07:38 UTC · lore

Description: k@samael /localhome/k/git.git/git/gitweb % git-blame --incremental zsh: segmentation fault git blame --incremental

The 3rd branch in builtin-blame.c should also check for lacking arguments. Running that in top dir avoids the problem because the 'prefix' is NULL. The --incremental is no to blame here, it only triggers the segfault and even without that flag it goes checking argv too far.

I didn't check the pu branch, and I'm sorry if this is a dupe.

cheers, Tommi "Kynde" Kyntola

Show changes to builtin-blame.c +2 −0
diff --git a/builtin-blame.c b/builtin-blame.c
index 7a5665f..6d51b1f 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -2211,6 +2211,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];

← back to recent threads