|
|
|
@ -53,7 +53,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(struct ares_addr *addr, struct hostent **host); |
|
|
|
|
static void ptr_rr_name(char *name, const struct ares_addr *addr); |
|
|
|
|
static void ptr_rr_name(char *name, int name_size, const struct ares_addr *addr); |
|
|
|
|
|
|
|
|
|
void ares_gethostbyaddr(ares_channel channel, const void *addr, int addrlen, |
|
|
|
|
int family, ares_host_callback callback, void *arg) |
|
|
|
@ -105,7 +105,7 @@ static void next_lookup(struct addr_query *aquery) |
|
|
|
|
switch (*p) |
|
|
|
|
{ |
|
|
|
|
case 'b': |
|
|
|
|
ptr_rr_name(name, &aquery->addr); |
|
|
|
|
ptr_rr_name(name, sizeof(name), &aquery->addr); |
|
|
|
|
aquery->remaining_lookups = p + 1; |
|
|
|
|
ares_query(aquery->channel, name, C_IN, T_PTR, addr_callback, |
|
|
|
|
aquery); |
|
|
|
@ -255,7 +255,7 @@ static int file_lookup(struct ares_addr *addr, struct hostent **host) |
|
|
|
|
return status; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void ptr_rr_name(char *name, const struct ares_addr *addr) |
|
|
|
|
static void ptr_rr_name(char *name, int name_size, const struct ares_addr *addr) |
|
|
|
|
{ |
|
|
|
|
if (addr->family == AF_INET) |
|
|
|
|
{ |
|
|
|
@ -264,20 +264,20 @@ static void ptr_rr_name(char *name, const struct ares_addr *addr) |
|
|
|
|
unsigned long a2 = (laddr >> 16UL) & 0xFFUL; |
|
|
|
|
unsigned long a3 = (laddr >> 8UL) & 0xFFUL; |
|
|
|
|
unsigned long a4 = laddr & 0xFFUL; |
|
|
|
|
sprintf(name, "%lu.%lu.%lu.%lu.in-addr.arpa", a4, a3, a2, a1); |
|
|
|
|
snprintf(name, name_size, "%lu.%lu.%lu.%lu.in-addr.arpa", a4, a3, a2, a1); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
unsigned char *bytes = (unsigned char *)&addr->addrV6; |
|
|
|
|
/* There are too many arguments to do this in one line using
|
|
|
|
|
* minimally C89-compliant compilers */ |
|
|
|
|
sprintf(name, |
|
|
|
|
snprintf(name, name_size, |
|
|
|
|
"%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.", |
|
|
|
|
bytes[15]&0xf, bytes[15] >> 4, bytes[14]&0xf, bytes[14] >> 4, |
|
|
|
|
bytes[13]&0xf, bytes[13] >> 4, bytes[12]&0xf, bytes[12] >> 4, |
|
|
|
|
bytes[11]&0xf, bytes[11] >> 4, bytes[10]&0xf, bytes[10] >> 4, |
|
|
|
|
bytes[9]&0xf, bytes[9] >> 4, bytes[8]&0xf, bytes[8] >> 4); |
|
|
|
|
sprintf(name+strlen(name), |
|
|
|
|
snprintf(name+strlen(name), name_size-strlen(name), |
|
|
|
|
"%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.%x.ip6.arpa", |
|
|
|
|
bytes[7]&0xf, bytes[7] >> 4, bytes[6]&0xf, bytes[6] >> 4, |
|
|
|
|
bytes[5]&0xf, bytes[5] >> 4, bytes[4]&0xf, bytes[4] >> 4, |
|
|
|
|