Skip to contentSkip to conversation

git-blame: Fix overrun in fake_working_tree_commit()

PATCH New Michael Spang 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-blame: Fix overrun in fake_working_tree_commit()

git-blame would overflow commit->buffer when annotating files with long paths.

---
 builtin-blame.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
builtin-blame.c +1 -1
index 60ec535..bc86bda 100644
@@ -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"