diff options
-rw-r--r-- | src/resolv/async_resolv.c | 6 | ||||
-rw-r--r-- | src/resolv/async_resolv.h | 7 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/resolv/async_resolv.c b/src/resolv/async_resolv.c index 4cbb56d82..ef76f1711 100644 --- a/src/resolv/async_resolv.c +++ b/src/resolv/async_resolv.c @@ -1314,7 +1314,9 @@ resolv_gethostbyname_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, } char * -resolv_get_string_address(TALLOC_CTX *mem_ctx, struct resolv_hostent *hostent) +resolv_get_string_address_index(TALLOC_CTX *mem_ctx, + struct resolv_hostent *hostent, + unsigned int addrindex) { char *address; @@ -1327,7 +1329,7 @@ resolv_get_string_address(TALLOC_CTX *mem_ctx, struct resolv_hostent *hostent) } errno = 0; - if (inet_ntop(hostent->family, hostent->addr_list[0]->ipaddr, + if (inet_ntop(hostent->family, hostent->addr_list[addrindex]->ipaddr, address, 128) == NULL) { DEBUG(1, ("inet_ntop failed [%d][%s].\n", errno, strerror(errno))); talloc_free(address); diff --git a/src/resolv/async_resolv.h b/src/resolv/async_resolv.h index 0e2030324..8f8ddcbdc 100644 --- a/src/resolv/async_resolv.h +++ b/src/resolv/async_resolv.h @@ -122,7 +122,12 @@ int resolv_gethostbyname_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, struct resolv_hostent **rhostent); char * -resolv_get_string_address(TALLOC_CTX *mem_ctx, struct resolv_hostent *hostent); +resolv_get_string_address_index(TALLOC_CTX *mem_ctx, + struct resolv_hostent *hostent, + unsigned int addrindex); + +#define resolv_get_string_address(mem_ctx, hostent) \ + resolv_get_string_address_index(mem_ctx, hostent, 0) struct sockaddr_storage * resolv_get_sockaddr_address(TALLOC_CTX *mem_ctx, struct resolv_hostent *hostent, |