From: Jeff King Date: Thu, 24 Sep 2015 21:06:51 +0000 (-0400) Subject: grep: use xsnprintf to format failure message X-Git-Tag: v2.7.0-rc0~87^2~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=19bdd3e7e160a0b000c15d8bf6d33f4149e3f911;p=thirdparty%2Fgit.git grep: use xsnprintf to format failure message This looks at first glance like the sprintf can overflow our buffer, but it's actually fine; the p->origin string is something constant and small, like "command line" or "-e option". Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- diff --git a/grep.c b/grep.c index b58c7c6434..6c68d5bd2e 100644 --- a/grep.c +++ b/grep.c @@ -306,9 +306,9 @@ static NORETURN void compile_regexp_failed(const struct grep_pat *p, char where[1024]; if (p->no) - sprintf(where, "In '%s' at %d, ", p->origin, p->no); + xsnprintf(where, sizeof(where), "In '%s' at %d, ", p->origin, p->no); else if (p->origin) - sprintf(where, "%s, ", p->origin); + xsnprintf(where, sizeof(where), "%s, ", p->origin); else where[0] = 0;