Skip to content

Commit 6f98725

Browse files
author
Junio C Hamano
committed
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. The bug was triggered by commit febf7ea from linux-2.6. Jeff King originally fixed it by looking back only one character; Johannes Schindelin pointed out that we could try harder while at it to cope with commits with broken headers. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent bca7325 commit 6f98725

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

builtin-shortlog.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ static void read_from_stdin(struct path_list *list)
188188
bob = buffer + strlen(buffer);
189189
else {
190190
offset = 8;
191-
if (isspace(bob[-1]))
191+
while (buffer + offset < bob &&
192+
isspace(bob[-1]))
192193
bob--;
193194
}
194195

0 commit comments

Comments
 (0)