[PATCH] shortlog: fix segfault on empty authorname

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Junio C Hamano <junkio@...>
Cc: Nicolas Pitre <nico@...>, <git@...>, Johannes Schindelin <Johannes.Schindelin@...>
Date: Saturday, December 9, 2006 - 12:04 am

The old code looked backwards from the email address to parse the name,
allowing an arbitrary number of spaces between the two. However, in the case
of no name, we looked back too far to the 'author' (or 'Author:') header.
Instead, remove at most one space between name and address.

The bug was triggered by commit febf7ea4bed from linux-2.6.

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin-shortlog.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index f1124e2..7a2ddfe 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -188,7 +188,7 @@ static void read_from_stdin(struct path_list *list)
 				bob = buffer + strlen(buffer);
 			else {
 				offset = 8;
-				while (isspace(bob[-1]))
+				if (isspace(bob[-1]))
 					bob--;
 			}
 
@@ -236,7 +236,7 @@ static void get_from_rev(struct rev_info *rev, struct path_list *list)
 					author = scratch;
 					authorlen = strlen(scratch);
 				} else {
-					while (bracket[-1] == ' ')
+					if (bracket[-1] == ' ')
 						bracket--;
 
 					author = buffer + 7;
-- 
1.4.4.2.g3528-dirty

On Fri, Dec 08, 2006 at 10:23:14PM -0500, Nicolas Pitre wrote:

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
builtin git-shortlog still broken, Nicolas Pitre, (Fri Dec 8, 11:23 pm)
Re: builtin git-shortlog still broken, Johannes Schindelin, (Sat Dec 9, 7:34 pm)
[PATCH] shortlog: fix segfault on empty authorname, Jeff King, (Sat Dec 9, 12:04 am)
Re: [PATCH] shortlog: fix segfault on empty authorname, Johannes Schindelin, (Sat Dec 9, 7:21 pm)
Re: [PATCH] shortlog: fix segfault on empty authorname, Johannes Schindelin, (Sun Dec 10, 6:43 pm)
Re: [PATCH] shortlog: fix segfault on empty authorname, Junio C Hamano, (Sun Dec 10, 2:01 am)
Re: [PATCH] shortlog: fix segfault on empty authorname, Nicolas Pitre, (Sat Dec 9, 5:56 pm)