From 15c304225ffe75bfbb85e8819918d3c7ca0572fe Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 3 Dec 2007 19:57:18 +0000 Subject: Fix three issues previous cleanup introduces. --- ares/ares_gethostbyaddr.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'ares/ares_gethostbyaddr.c') diff --git a/ares/ares_gethostbyaddr.c b/ares/ares_gethostbyaddr.c index b6836d053..909132e77 100644 --- a/ares/ares_gethostbyaddr.c +++ b/ares/ares_gethostbyaddr.c @@ -58,8 +58,7 @@ static void addr_callback(void *arg, int status, int timeouts, static void end_aquery(struct addr_query *aquery, int status, struct hostent *host); static int file_lookup(union ares_addr *addr, int family, struct hostent **host); -static void ptr_rr_name(char *name, size_t len, int family, - union ares_addr *addr); +static void ptr_rr_name(char *name, int family, union ares_addr *addr); void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen, int family, ares_host_callback callback, void *arg) @@ -111,7 +110,7 @@ static void next_lookup(struct addr_query *aquery) switch (*p) { case 'b': - ptr_rr_name(name, sizeof(name), aquery->family, &aquery->addr); + ptr_rr_name(name, aquery->family, &aquery->addr); aquery->remaining_lookups = p + 1; ares_query(aquery->channel, name, C_IN, T_PTR, addr_callback, aquery); @@ -245,21 +244,21 @@ static int file_lookup(union ares_addr *addr, int family, struct hostent **host) return status; } -static void ptr_rr_name(char *name, size_t len, int family, - union ares_addr *addr) { +static void ptr_rr_name(char *name, int family, union ares_addr *addr) +{ if (family == AF_INET) { - in_addr_t s_addr = ntohl(addr->addr4.s_addr); - int a1 = (int)((s_addr >> 24) & 0xff); - int a2 = (int)((s_addr >> 16) & 0xff); - int a3 = (int)((s_addr >> 8) & 0xff); - int a4 = (int)(s_addr & 0xff); - snprintf(name, len, "%d.%d.%d.%d.in-addr.arpa", a4, a3, a2, a1); + unsigned long laddr = ntohl(addr->addr4.s_addr); + int a1 = (int)((laddr >> 24) & 0xff); + int a2 = (int)((laddr >> 16) & 0xff); + int a3 = (int)((laddr >> 8) & 0xff); + int a4 = (int)(laddr & 0xff); + sprintf(name, "%d.%d.%d.%d.in-addr.arpa", a4, a3, a2, a1); } else { unsigned char *bytes = (unsigned char *)&addr->addr6.s6_addr; - snprintf(name, len, + sprintf(name, "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x." "%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.ip6.arpa", bytes[15]&0xf, bytes[15] >> 4, bytes[14]&0xf, bytes[14] >> 4, -- cgit v1.2.3