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

[PATCH] Fix an off by one bug in pretty.c

From
MCMarco Costalba <mcostalba@gmail.com>
Date
Jan 5, 2008, 22:55 UTC
Message-ID
<e5bfff550801051455i3d589c4q9375aeab0cb6aa47@mail.gmail.com>

In case author email is <> then we have the following bug in function 'format_person_part'

/* parse name */
for (end = 0; end < len && msg[end] != '<'; end++)
       ; /* do nothing */
start = end + 1; /* now start points to '>' */
-- cut ---

/* parse email */ for (end = start + 1; end < len && msg[end] != '>'; end++)

And here 'end' is initialized with 'start + 1' instead of 'start'. This turns out in empty commit date when git log is used with --pretty=format option.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
---
 pretty.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/pretty.c b/pretty.c
index 5b1078b..0b2f187 100644
--- a/pretty.c
+++ b/pretty.c
@@ -292,7 +292,7 @@ static void format_person_part
 	/* parse name */
 	for (end = 0; end < len && msg[end] != '<'; end++)
 		; /* do nothing */
-	start = end + 1;
+	start = end;
 	while (end > 0 && isspace(msg[end - 1]))
 		end--;
 	if (part == 'n') {	/* name */
-- 
1.5.4.rc2.38.gd6da3-dirty
Next: Marco Costalba
Message 1 of 2 in “Fix an off by one bug in pretty.c”
  1. Fix an off by one bug in pretty.cMarco Costalba, Jan 5, 2008
  2. Marco CostalbaJan 5, 2008

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.