diff --git a/lib/replace/inet_ntop.c b/lib/replace/inet_ntop.c index fb3d8e90c8a..d6d4158d975 100644 --- a/lib/replace/inet_ntop.c +++ b/lib/replace/inet_ntop.c @@ -65,20 +65,22 @@ rep_inet_ntop(int af, const void *src, char *dst, socklen_t size) * format an IPv4 address * return: * `dst' (as a const) - * notes: - * (1) uses no statics - * (2) takes a unsigned char* not an in_addr as input * author: * Paul Vixie, 1996. */ static const char * inet_ntop4(const unsigned char *src, char *dst, socklen_t size) { - static const char *fmt = "%u.%u.%u.%u"; - char tmp[sizeof "255.255.255.255"]; + char tmp[sizeof("255.255.255.255")]; size_t len; - len = snprintf(tmp, sizeof tmp, fmt, src[0], src[1], src[2], src[3]); + len = snprintf(tmp, + sizeof(tmp), + "%hhu.%hhu.%hhu.%hhu", + src[0], + src[1], + src[2], + src[3]); if (len >= size) { errno = ENOSPC; return (NULL);