From 9130ac9fe17831445690ebbb60f09b86f96516b3 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Thu, 7 Oct 2010 14:25:43 -0400 Subject: rev-list: handle %x00 NUL in user format The code paths for showing commits in "git log" and "git rev-list --graph" correctly handle embedded NULs by looking only at the resulting strbuf's length, and never treating it as a C string. The code path for regular rev-list, however, used printf("%s"), which resulted in truncated output. This patch uses fwrite instead, like the --graph code path. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- builtin/rev-list.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'builtin/rev-list.c') diff --git a/builtin/rev-list.c b/builtin/rev-list.c index efe9360e2..3b2dca080 100644 --- a/builtin/rev-list.c +++ b/builtin/rev-list.c @@ -147,8 +147,10 @@ static void show_commit(struct commit *commit, void *data) } } else { if (revs->commit_format != CMIT_FMT_USERFORMAT || - buf.len) - printf("%s%c", buf.buf, info->hdr_termination); + buf.len) { + fwrite(buf.buf, 1, buf.len, stdout); + putchar(info->hdr_termination); + } } strbuf_release(&buf); } else { -- cgit v1.2.1