shortlog: fix segfault on empty authorname
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> Signed-off-by: Junio C Hamano <junkio@cox.net>
Jeff King committed
Dec 8, 2006 at 23:04 UTC
90ffefe564cd849f88b1d1b5817eb25e3d57521b
1 file changed
+2
-2
builtin-shortlog.c
+2
-2
@@ -188,7 +188,7 @@ static void read_from_stdin(struct path_list *list)
188
bob = buffer + strlen(buffer);
189
else {
190
offset = 8;
191
- while (isspace(bob[-1]))
191
+ if (isspace(bob[-1]))
192
bob--;
193
}
194
@@ -236,7 +236,7 @@ static void get_from_rev(struct rev_info *rev, struct path_list *list)
236
author = scratch;
237
authorlen = strlen(scratch);
238
} else {
239
- while (bracket[-1] == ' ')
239
+ if (bracket[-1] == ' ')
240
bracket--;
241
242
author = buffer + 7;