summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-09-24 21:06:51 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-09-25 17:18:18 (GMT)
commit19bdd3e7e160a0b000c15d8bf6d33f4149e3f911 (patch)
tree4afb39180ae8a79401ffd02774d6b9523c156168
parent48bdf86995423736f36557d744841b08c8bf4e14 (diff)
downloadgit-19bdd3e7e160a0b000c15d8bf6d33f4149e3f911.zip
git-19bdd3e7e160a0b000c15d8bf6d33f4149e3f911.tar.gz
git-19bdd3e7e160a0b000c15d8bf6d33f4149e3f911.tar.bz2
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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--grep.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/grep.c b/grep.c
index b58c7c6..6c68d5b 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;