[PATCH] shortlog: fix segfault on empty authorname

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
---
 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:

> On the Linux kernel repository, doing "git shortlog v2.6.18.." works 
> fine. "git shortlog v2.6.17.." works fine. "git shortlog v2.6.16.." also 
> works fine.  But "git shortlog v2.6.15.." dies with a segmentation 
> fault.  Trying "git log v2.6.15.. | git shortlog" also produces the same 
> crash while "git log v2.6.16.. | git shortlog" works fine.
> 
> The old perl version doesn't have any such issue with those test cases, 
> not even with the whole kernel history.
> 
> 
> Nicolas
> -
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]