we cannot use inet_ntoa(3), here. so, use inet_ntop(3), instead.

This commit is contained in:
Hajimu UMEMOTO 2005-04-29 12:01:36 +00:00
parent e47099593a
commit 0d389e7212
2 changed files with 11 additions and 5 deletions

View File

@ -532,7 +532,7 @@ _dns_gethostbyaddr(void *rval, void *cb_data, va_list ap)
struct hostent *rhe; struct hostent *rhe;
char **haddr; char **haddr;
u_long old_options; u_long old_options;
char hname2[MAXDNAME+1]; char hname2[MAXDNAME+1], numaddr[46];
#endif /*SUNSECURITY*/ #endif /*SUNSECURITY*/
addr = va_arg(ap, const char *); addr = va_arg(ap, const char *);
@ -625,9 +625,11 @@ _dns_gethostbyaddr(void *rval, void *cb_data, va_list ap)
_res.options |= RES_DEFNAMES; _res.options |= RES_DEFNAMES;
memset(&rhd, 0, sizeof rhd); memset(&rhd, 0, sizeof rhd);
if (!(rhe = gethostbyname_r(hname2, &rhd.host, &rhd.data))) { 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, syslog(LOG_NOTICE|LOG_AUTH,
"gethostbyaddr: No A record for %s (verifying [%s])", "gethostbyaddr: No A record for %s (verifying [%s])",
hname2, inet_ntoa(*((struct in_addr *)addr))); hname2, numaddr);
_res.options = old_options; _res.options = old_options;
h_errno = HOST_NOT_FOUND; h_errno = HOST_NOT_FOUND;
return NS_NOTFOUND; return NS_NOTFOUND;
@ -637,9 +639,11 @@ _dns_gethostbyaddr(void *rval, void *cb_data, va_list ap)
if (!memcmp(*haddr, addr, INADDRSZ)) if (!memcmp(*haddr, addr, INADDRSZ))
break; break;
if (!*haddr) { if (!*haddr) {
if (inet_ntop(af, addr, numaddr, sizeof(numaddr)) == NULL)
strlcpy(numaddr, "UNKNOWN", sizeof(numaddr));
syslog(LOG_NOTICE|LOG_AUTH, syslog(LOG_NOTICE|LOG_AUTH,
"gethostbyaddr: A record of %s != PTR record [%s]", "gethostbyaddr: A record of %s != PTR record [%s]",
hname2, inet_ntoa(*((struct in_addr *)addr))); hname2, numaddr);
h_errno = HOST_NOT_FOUND; h_errno = HOST_NOT_FOUND;
return NS_NOTFOUND; return NS_NOTFOUND;
} }

View File

@ -171,6 +171,7 @@ _gethostbynisaddr_r(const char *addr, int len, int af, struct hostent *he,
struct hostent_data *hed) struct hostent_data *hed)
{ {
char *map; char *map;
char numaddr[46];
switch (af) { switch (af) {
case AF_INET: case AF_INET:
@ -180,8 +181,9 @@ _gethostbynisaddr_r(const char *addr, int len, int af, struct hostent *he,
map = "ipnodes.byaddr"; map = "ipnodes.byaddr";
break; break;
} }
return _gethostbynis(inet_ntoa(*(struct in_addr *)addr), map, af, he, if (inet_ntop(af, addr, numaddr, sizeof(numaddr)) == NULL)
hed); return -1;
return _gethostbynis(numaddr, map, af, he, hed);
} }
#endif /* YP */ #endif /* YP */