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

[PATCH] git-blame: Fix overrun in fake_working_tree_commit()

From
MSMichael Spang <mspang@uwaterloo.ca>
Date
Apr 14, 2007, 21:26 UTC
Message-ID
<462146FC.9060202@uwaterloo.ca>
git-blame would overflow commit->buffer when annotating files with long paths.
Signed-off-by: Michael Spang <mspang@uwaterloo.ca>
---
 builtin-blame.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/builtin-blame.c b/builtin-blame.c
index 60ec535..bc86bda 100644
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -2041,7 +2041,7 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con
 
 	commit->buffer = xmalloc(400);
 	ident = fmt_ident("Not Committed Yet", "not.committed.yet", NULL, 0);
-	sprintf(commit->buffer,
+	snprintf(commit->buffer, 400,
 		"tree 0000000000000000000000000000000000000000\n"
 		"parent %s\n"
 		"author %s\n"
Message 1 of 1 in “git-blame: Fix overrun in fake_working_tree_commit()”
  1. git-blame: Fix overrun in fake_working_tree_commit()Michael Spang, Apr 14, 2007

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.