threads / patch / 7654

patchgit-blame: Fix overrun in fake_working_tree_commit()

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

## tl;dr

One message between Apr 14, 2007 and Apr 14, 2007. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Michael Spang· Apr 14, 2007, 21:26 UTC · lore
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(-)
Show changes to builtin-blame.c +1 −1
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"

← back to recent threads