[PATCH 20/68] compat/hstrerror: convert sprintf to snprintf
- From
Jeff King <peff@peff.net>
- Date
- Sep 24, 2015, 21:06 UTC
- Message-ID
- <20150924210648.GQ30946@sigill.intra.peff.net>
- In-Reply-To
- <20150924210225.GA23624@sigill.intra.peff.net>
This is a trivially correct use of sprintf, as our error number should not be excessively long. But it's still nice to drop an sprintf call.
Note that we cannot use xsnprintf here, because this is compat code which does not load git-compat-util.h.
Signed-off-by: Jeff King <peff@peff.net> --- compat/hstrerror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/compat/hstrerror.c b/compat/hstrerror.c index 069c555..b85a2fa 100644 --- a/compat/hstrerror.c +++ b/compat/hstrerror.c @@ -16,6 +16,6 @@ const char *githstrerror(int err) case TRY_AGAIN: return "Non-authoritative \"host not found\", or SERVERFAIL"; } - sprintf(buffer, "Name resolution error %d", err); + snprintf(buffer, sizeof(buffer), "Name resolution error %d", err); return buffer; }
-- 2.6.0.rc3.454.g204ad51