1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

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
This commit is contained in:
Andreas Schneider 2023-04-06 16:17:16 +02:00 committed by Andreas Schneider
parent f1209a7a15
commit ad7418d23f

View File

@ -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);