From: Nikos Mavrogiannopoulos Date: Thu, 19 Mar 2015 10:03:24 +0000 (+0100) Subject: inet_ntop replacement: do not depend on socklen_t X-Git-Tag: gnutls_3_4_0~171 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=cc2c356efa1868a024f9e77221546ce9ec4d332e;p=thirdparty%2Fgnutls.git inet_ntop replacement: do not depend on socklen_t --- diff --git a/lib/inet_ntop.c b/lib/inet_ntop.c index e7d52f0c59..2224dbad25 100644 --- a/lib/inet_ntop.c +++ b/lib/inet_ntop.c @@ -57,9 +57,9 @@ */ typedef int verify_int_size[4 <= sizeof (int) ? 1 : -1]; -static const char *inet_ntop4 (const unsigned char *src, char *dst, socklen_t size); +static const char *inet_ntop4 (const unsigned char *src, char *dst, unsigned size); # if HAVE_IPV6 -static const char *inet_ntop6 (const unsigned char *src, char *dst, socklen_t size); +static const char *inet_ntop6 (const unsigned char *src, char *dst, unsigned size); # endif @@ -73,7 +73,7 @@ static const char *inet_ntop6 (const unsigned char *src, char *dst, socklen_t si */ const char * inet_ntop (int af, const void *restrict src, - char *restrict dst, socklen_t cnt) + char *restrict dst, unsigned cnt) { switch (af) { @@ -106,7 +106,7 @@ inet_ntop (int af, const void *restrict src, * Paul Vixie, 1996. */ static const char * -inet_ntop4 (const unsigned char *src, char *dst, socklen_t size) +inet_ntop4 (const unsigned char *src, char *dst, unsigned size) { char tmp[sizeof "255.255.255.255"]; int len; @@ -133,7 +133,7 @@ inet_ntop4 (const unsigned char *src, char *dst, socklen_t size) * Paul Vixie, 1996. */ static const char * -inet_ntop6 (const unsigned char *src, char *dst, socklen_t size) +inet_ntop6 (const unsigned char *src, char *dst, unsigned size) { /* * Note that int32_t and int16_t need only be "at least" large enough @@ -230,7 +230,7 @@ inet_ntop6 (const unsigned char *src, char *dst, socklen_t size) /* * Check for overflow, copy, and we're done. */ - if ((socklen_t) (tp - tmp) > size) + if ((unsigned) (tp - tmp) > size) { errno = ENOSPC; return NULL; diff --git a/lib/system.h b/lib/system.h index 9f4fc33c01..03cf7fd494 100644 --- a/lib/system.h +++ b/lib/system.h @@ -115,7 +115,7 @@ int inet_pton(int af, const char *src, void *dst); #ifndef HAVE_INET_NTOP # define inet_ntop _gnutls_inet_ntop const char *inet_ntop(int af, const void *src, - char *dst, socklen_t size); + char *dst, unsigned size); #endif #endif /* SYSTEM_H */