Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

mailmap: avoid out-of-bounds memory access

AddressSanitizer (
complains of a one-byte buffer underflow in parse_name_and_email() while
running the test suite. And indeed, if one of the lines in the mailmap
begins with '<', we dereference the address just before the beginning of
the buffer when looking for whitespace to remove, before checking that
we aren't going too far.

So reverse the order of the tests to make sure that we don't read
outside the buffer.

Signed-off-by: Romain Francoise <>
Signed-off-by: Jeff King <>
  • Loading branch information...
commit 3174bc5ccfea34717a8dac2175c1951239a4985d 1 parent 7e20105
@orebokech orebokech authored peff committed
Showing with 1 addition and 1 deletion.
  1. +1 −1  mailmap.c
2  mailmap.c
@@ -118,7 +118,7 @@ static char *parse_name_and_email(char *buffer, char **name,
while (isspace(*nstart) && nstart < left)
nend = left-1;
- while (isspace(*nend) && nend > nstart)
+ while (nend > nstart && isspace(*nend))
*name = (nstart < nend ? nstart : NULL);
Please sign in to comment.
Something went wrong with that request. Please try again.