diff options
author | Andreas Schneider <asn@samba.org> | 2023-04-06 16:17:16 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2023-04-11 10:08:54 +0000 |
commit | ad7418d23f891227bb8302d0514f82fcd438280c (patch) | |
tree | 475f0d8ea72f5532059cabc6f26177cca694bf58 /lib/replace | |
parent | f1209a7a15dc9a08071873d27946953558dfc15c (diff) | |
download | samba-ad7418d23f891227bb8302d0514f82fcd438280c.tar.gz |
lib:replace: Fix snprintf of rep_inet_ntop()
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Tue Apr 11 10:08:54 UTC 2023 on atb-devel-224
Diffstat (limited to 'lib/replace')
-rw-r--r-- | lib/replace/inet_ntop.c | 14 |
1 files changed, 8 insertions, 6 deletions
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); |