git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-blame: prevent argument parsing segfault

From
TKTommi Kyntola <tommi.kyntola@ray.fi>
Date
Feb 16, 2007, 07:38 UTC
Message-ID
<45D55F6D.5090900@ray.fi>

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

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];
Next: Junio C Hamano
Message 1 of 2 in “git-blame: prevent argument parsing segfault”
  1. git-blame: prevent argument parsing segfaultTommi Kyntola, Feb 16, 2007
  2. Junio C HamanoFeb 16, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.