From: Jeff King Date: Fri, 08 Jul 2016 09:25:26 GMT Subject: [PATCH 2/2] avoid using sha1_to_hex output as printf format Message-ID: <20160708092526.GB18263@sigill.intra.peff.net> In-Reply-To: <20160708092510.GB17072@sigill.intra.peff.net> We know that it should not contain any percent-signs, but it's a good habit not to feed non-literals to printf formatters. Signed-off-by: Jeff King --- builtin/worktree.c | 2 +- commit.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/worktree.c b/builtin/worktree.c index e866844..cce555c 100644 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@ -262,7 +262,7 @@ static int add_worktree(const char *path, const char *refname, */ strbuf_reset(&sb); strbuf_addf(&sb, "%s/HEAD", sb_repo.buf); - write_file(sb.buf, sha1_to_hex(null_sha1)); + write_file(sb.buf, "%s", sha1_to_hex(null_sha1)); strbuf_reset(&sb); strbuf_addf(&sb, "%s/commondir", sb_repo.buf); write_file(sb.buf, "../.."); diff --git a/commit.c b/commit.c index 3f4f371..9603379 100644 --- a/commit.c +++ b/commit.c @@ -1623,7 +1623,7 @@ void print_commit_list(struct commit_list *list, { for ( ; list; list = list->next) { const char *format = list->next ? format_cur : format_last; - printf(format, oid_to_hex(&list->item->object.oid)); + printf(format, "%s", oid_to_hex(&list->item->object.oid)); } } -- 2.9.0.393.g704e522