From 3a568cbe4a3fb67af9a46789a00206482e9c8207 Mon Sep 17 00:00:00 2001 From: ume Date: Fri, 29 Apr 2005 12:01:36 +0000 Subject: we cannot use inet_ntoa(3), here. so, use inet_ntop(3), instead. --- lib/libc/net/gethostbydns.c | 10 +++++++--- lib/libc/net/gethostbynis.c | 6 ++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/libc/net/gethostbydns.c b/lib/libc/net/gethostbydns.c index 1077bb8..bd4d02d 100644 --- a/lib/libc/net/gethostbydns.c +++ b/lib/libc/net/gethostbydns.c @@ -532,7 +532,7 @@ _dns_gethostbyaddr(void *rval, void *cb_data, va_list ap) struct hostent *rhe; char **haddr; u_long old_options; - char hname2[MAXDNAME+1]; + char hname2[MAXDNAME+1], numaddr[46]; #endif /*SUNSECURITY*/ addr = va_arg(ap, const char *); @@ -625,9 +625,11 @@ _dns_gethostbyaddr(void *rval, void *cb_data, va_list ap) _res.options |= RES_DEFNAMES; memset(&rhd, 0, sizeof rhd); if (!(rhe = gethostbyname_r(hname2, &rhd.host, &rhd.data))) { + if (inet_ntop(af, addr, numaddr, sizeof(numaddr)) == NULL) + strlcpy(numaddr, "UNKNOWN", sizeof(numaddr)); syslog(LOG_NOTICE|LOG_AUTH, "gethostbyaddr: No A record for %s (verifying [%s])", - hname2, inet_ntoa(*((struct in_addr *)addr))); + hname2, numaddr); _res.options = old_options; h_errno = HOST_NOT_FOUND; return NS_NOTFOUND; @@ -637,9 +639,11 @@ _dns_gethostbyaddr(void *rval, void *cb_data, va_list ap) if (!memcmp(*haddr, addr, INADDRSZ)) break; if (!*haddr) { + if (inet_ntop(af, addr, numaddr, sizeof(numaddr)) == NULL) + strlcpy(numaddr, "UNKNOWN", sizeof(numaddr)); syslog(LOG_NOTICE|LOG_AUTH, "gethostbyaddr: A record of %s != PTR record [%s]", - hname2, inet_ntoa(*((struct in_addr *)addr))); + hname2, numaddr); h_errno = HOST_NOT_FOUND; return NS_NOTFOUND; } diff --git a/lib/libc/net/gethostbynis.c b/lib/libc/net/gethostbynis.c index 386b312..e9cc205 100644 --- a/lib/libc/net/gethostbynis.c +++ b/lib/libc/net/gethostbynis.c @@ -171,6 +171,7 @@ _gethostbynisaddr_r(const char *addr, int len, int af, struct hostent *he, struct hostent_data *hed) { char *map; + char numaddr[46]; switch (af) { case AF_INET: @@ -180,8 +181,9 @@ _gethostbynisaddr_r(const char *addr, int len, int af, struct hostent *he, map = "ipnodes.byaddr"; break; } - return _gethostbynis(inet_ntoa(*(struct in_addr *)addr), map, af, he, - hed); + if (inet_ntop(af, addr, numaddr, sizeof(numaddr)) == NULL) + return -1; + return _gethostbynis(numaddr, map, af, he, hed); } #endif /* YP */ -- cgit v1.1