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

[PATCH] Prevent git blame from segfaulting on a missing author name

From
DRDavid Reiss <dreiss@facebook.com>
Date
Dec 22, 2009, 04:22 UTC
Message-ID
<4B304993.2040600@facebook.com>

The author name should never be missing in a valid commit, but git shouldn't segfault no matter what is in the object database.

Signed-off-by: David Reiss <dreiss@facebook.com>
---
git blame was segfaulting on a repro produced by piping mtn git_export
from the Pidgin repository to git fast-import.  This was the most obvious
fix, but I'm not sure if it is the best solution.
Here's a script that reproduces the segfault.

#!/bin/sh set -e git init echo line > afile git add afile TREE=`git write-tree` cat >badcommit <<EOF tree $TREE author <noname> 1234567890 +0000 committer David Reiss <dreiss@facebook.com> 1234567890 +0000

some message EOF COMMIT=`git hash-object -t commit -w badcommit` echo "git --no-pager blame $COMMIT -- afile" git --no-pager blame $COMMIT -- afile

 builtin-blame.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/builtin-blame.c b/builtin-blame.c
index d4e25a5..5e19c79 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -1326,7 +1326,7 @@ static void get_ac_line(const char *inbuf, const char *what,
 	timepos = tmp;
 
 	*tmp = 0;
-	while (*tmp != ' ')
+	while (tmp > person && *tmp != ' ')
 		tmp--;
 	mailpos = tmp + 1;
 	*tmp = 0;
-- 
1.6.3.3
Next: Junio C Hamano
Message 1 of 2 in “Prevent git blame from segfaulting on a missing author name”
  1. Prevent git blame from segfaulting on a missing author nameDavid Reiss, Dec 22, 2009
  2. Junio C HamanoDec 22, 2009

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.