From: David Reiss <dreiss@facebook•com>
To: <git@vger•kernel.org>
Subject: [PATCH] Prevent git blame from segfaulting on a missing author name
Date: Mon, 21 Dec 2009 20:22:43 -0800 [thread overview]
Message-ID: <4B304993.2040600@facebook.com> (raw)
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 reply other threads:[~2009-12-22 6:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-22 4:22 David Reiss [this message]
2009-12-22 7:25 ` [PATCH] Prevent git blame from segfaulting on a missing author name Junio C Hamano
-- strict thread matches above, loose matches on Subject: below --
2009-12-22 18:51 David Reiss
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B304993.2040600@facebook.com \
--to=dreiss@facebook$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox