git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] mailmap: avoid out-of-bounds memory access

From
Romain Francoise <romain@orebokech.com>
Date
Oct 27, 2012, 22:49 UTC
Message-ID
<87k3ub4jjg.fsf@silenus.orebokech.com>

AddressSanitizer (http://clang.llvm.org/docs/AddressSanitizer.html) 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 <romain@orebokech.com>
---
 mailmap.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mailmap.c b/mailmap.c
index 47aa419..ea4b471 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -118,7 +118,7 @@ static char *parse_name_and_email(char *buffer, char **name,
 	while (isspace(*nstart) && nstart < left)
 		++nstart;
 	nend = left-1;
-	while (isspace(*nend) && nend > nstart)
+	while (nend > nstart && isspace(*nend))
 		--nend;
 
 	*name = (nstart < nend ? nstart : NULL);
-- 
1.7.10.4
Next: Jeff King
Message 1 of 3 in “mailmap: avoid out-of-bounds memory access”
  1. mailmap: avoid out-of-bounds memory accessRomain Francoise, Oct 27, 2012
  2. Jeff KingOct 28, 2012
  3. Romain FrancoiseOct 28, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.