diff options
Diffstat (limited to 'resolv')
-rw-r--r-- | resolv/gethnamaddr.c | 27 | ||||
-rw-r--r-- | resolv/inet_ntop.c | 10 | ||||
-rw-r--r-- | resolv/inet_pton.c | 21 | ||||
-rw-r--r-- | resolv/resolv.h | 3 |
4 files changed, 30 insertions, 31 deletions
diff --git a/resolv/gethnamaddr.c b/resolv/gethnamaddr.c index b80595b..18f4764 100644 --- a/resolv/gethnamaddr.c +++ b/resolv/gethnamaddr.c @@ -88,6 +88,12 @@ static char rcsid[] = "$Id$"; # include <../conf/options.h> #endif +#ifdef SPRINTF_CHAR +# define SPRINTF(x) strlen(sprintf/**/x) +#else +# define SPRINTF(x) sprintf x +#endif + #define MAXALIASES 35 #define MAXADDRS 35 #define MAXADDRBUFSIZE 8192 @@ -475,8 +481,7 @@ gethostbyname2(name, af) * Fake up a hostent as if we'd actually * done a lookup. */ - if (inet_pton(af, name, host_addr, - sizeof host_addr) <= 0) { + if (inet_pton(af, name, host_addr) <= 0) { h_errno = HOST_NOT_FOUND; return (NULL); } @@ -487,7 +492,7 @@ gethostbyname2(name, af) host.h_name = hostbuf; host.h_aliases = host_aliases; host_aliases[0] = NULL; - h_addr_ptrs[0] = (char *)&host_addr; + h_addr_ptrs[0] = (char *)host_addr; h_addr_ptrs[1] = NULL; host.h_addr_list = h_addr_ptrs; if (_res.options & RES_USE_INET6) @@ -617,9 +622,9 @@ gethostbyaddr(addr, len, af) case AF_INET6: qp = qbuf; for (n = IN6ADDRSZ - 1; n >= 0; n--) { - qp += sprintf(qp, "%x.%x.", - uaddr[n] & 0xf, - (uaddr[n] >> 4) & 0xf); + qp += SPRINTF((qp, "%x.%x.", + uaddr[n] & 0xf, + (uaddr[n] >> 4) & 0xf)); } strcpy(qp, "ip6.int"); break; @@ -770,12 +775,12 @@ _gethtent() goto again; *cp++ = '\0'; if ((_res.options & RES_USE_INET6) && - inet_pton(AF_INET6, p, host_addr, sizeof host_addr) > 0) { + inet_pton(AF_INET6, p, host_addr) > 0) { af = AF_INET6; len = IN6ADDRSZ; - } else if (inet_pton(AF_INET, p, host_addr, sizeof host_addr) > 0) { + } else if (inet_pton(AF_INET, p, host_addr) > 0) { if (_res.options & RES_USE_INET6) { - map_v4v6_address((char*)&host_addr, (char*)&host_addr); + map_v4v6_address((char*)host_addr, (char*)host_addr); af = AF_INET6; len = IN6ADDRSZ; } else { @@ -785,7 +790,7 @@ _gethtent() } else { goto again; } - h_addr_ptrs[0] = (char *)&host_addr; + h_addr_ptrs[0] = (char *)host_addr; h_addr_ptrs[1] = NULL; host.h_addr_list = h_addr_ptrs; host.h_length = len; @@ -859,7 +864,7 @@ struct hostent * _gethtbyname(name) const char *name; { - extern struct hostent *_gethtbyname2 __P((const char *, int)); + extern struct hostent *_gethtbyname2(); struct hostent *hp; if (_res.options & RES_USE_INET6) { diff --git a/resolv/inet_ntop.c b/resolv/inet_ntop.c index 71db06d..3b5795f 100644 --- a/resolv/inet_ntop.c +++ b/resolv/inet_ntop.c @@ -29,6 +29,12 @@ static char rcsid[] = "$Id$"; #include <stdio.h> #include "../conf/portability.h" +#ifdef SPRINTF_CHAR +# define SPRINTF(x) strlen(sprintf/**/x) +#else +# define SPRINTF(x) sprintf x +#endif + /* * WARNING: Don't even consider trying to compile this on a system where * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. @@ -84,7 +90,7 @@ inet_ntop4(src, dst, size) static const char fmt[] = "%u.%u.%u.%u"; char tmp[sizeof "255.255.255.255"]; - if (sprintf(tmp, fmt, src[0], src[1], src[2], src[3]) > size) { + if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) > size) { errno = ENOSPC; return (NULL); } @@ -170,7 +176,7 @@ inet_ntop6(src, dst, size) tp += strlen(tp); break; } - tp += sprintf(tp, "%x", words[i]); + tp += SPRINTF((tp, "%x", words[i])); } /* Was it a trailing run of 0x00's? */ if (best.base != -1 && (best.base + best.len) == (IN6ADDRSZ / INT16SZ)) diff --git a/resolv/inet_pton.c b/resolv/inet_pton.c index 385dc25..cfc069d 100644 --- a/resolv/inet_pton.c +++ b/resolv/inet_pton.c @@ -37,7 +37,7 @@ static int inet_pton4 __P((const char *src, u_char *dst)); static int inet_pton6 __P((const char *src, u_char *dst)); /* int - * inet_pton(af, src, dst, size) + * inet_pton(af, src, dst) * convert from presentation format (which usually means ASCII printable) * to network format (which is usually some kind of binary format). * return: @@ -48,24 +48,15 @@ static int inet_pton6 __P((const char *src, u_char *dst)); * Paul Vixie, 1996. */ int -inet_pton(af, src, dst, size) +inet_pton(af, src, dst) int af; const char *src; void *dst; - size_t size; { switch (af) { case AF_INET: - if (size < INADDRSZ) { - errno = ENOSPC; - return (-1); - } return (inet_pton4(src, dst)); case AF_INET6: - if (size < IN6ADDRSZ) { - errno = ENOSPC; - return (-1); - } return (inet_pton6(src, dst)); default: errno = EINVAL; @@ -207,12 +198,12 @@ inet_pton6(src, dst) * Since some memmove()'s erroneously fail to handle * overlapping regions, we'll do the shift by hand. */ - const howmany = tp - colonp; + const int n = tp - colonp; int i; - for (i = 1; i <= howmany; i++) { - endp[- i] = colonp[howmany - i]; - colonp[howmany - i] = 0; + for (i = 1; i <= n; i++) { + endp[- i] = colonp[n - i]; + colonp[n - i] = 0; } tp = endp; } diff --git a/resolv/resolv.h b/resolv/resolv.h index 0f5d5b8..f4320ff 100644 --- a/resolv/resolv.h +++ b/resolv/resolv.h @@ -245,9 +245,6 @@ int res_nameinquery __P((const char *, int, int, const u_char *, const u_char *)); int res_queriesmatch __P((const u_char *, const u_char *, const u_char *, const u_char *)); -/* XXX - these last two don't belong in the resolver */ -u_int inet_nsap_addr __P((const char *, u_char *, int maxlen)); -char *inet_nsap_ntoa __P((int, const u_char *, char *ascii)); __END_DECLS #endif /* !_RESOLV_H_ */ |