compat/hstrerror: convert sprintf to snprintf
authorJeff King <peff@peff.net>
Thu, 24 Sep 2015 21:06:48 +0000 (17:06 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 25 Sep 2015 17:18:18 +0000 (10:18 -0700)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/hstrerror.c
index 069c555da47ea168eea937fcc2d788294bf92ef5..b85a2fa9561f48657bc976a063560ddf7e00d449 100644 (file)
@@ -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;
 }