diff --git a/source4/libcli/resolve/dns_ex.c b/source4/libcli/resolve/dns_ex.c index 0bb3ba02287..0525d0d019a 100644 --- a/source4/libcli/resolve/dns_ex.c +++ b/source4/libcli/resolve/dns_ex.c @@ -81,7 +81,7 @@ struct dns_records_container { uint32_t count; }; -static int reply_to_addrs(TALLOC_CTX *mem_ctx, uint32_t *a_num, +static int reply_to_addrs(TALLOC_CTX *mem_ctx, uint32_t *addr_num, char ***cur_addrs, uint32_t total, struct dns_request *reply, int port) { @@ -151,8 +151,8 @@ static int reply_to_addrs(TALLOC_CTX *mem_ctx, uint32_t *a_num, rr->name->pLabelList->label); if (addrs[total]) { total++; - if (rr->type == QTYPE_A) { - (*a_num)++; + if (rr->type == QTYPE_A || rr->type == QTYPE_AAAA) { + (*addr_num)++; } } } @@ -211,7 +211,7 @@ static struct dns_records_container get_a_aaaa_records(TALLOC_CTX *mem_ctx, struct dns_request *reply; struct dns_records_container ret; char **addrs = NULL; - uint32_t a_num, total; + uint32_t addr_num, total; uint16_t qtype; TALLOC_CTX *tmp_ctx; DNS_ERROR err; @@ -236,12 +236,13 @@ static struct dns_records_container get_a_aaaa_records(TALLOC_CTX *mem_ctx, } } - a_num = total = 0; - total = reply_to_addrs(tmp_ctx, &a_num, &addrs, total, reply, port); + addr_num = total = 0; + total = reply_to_addrs(tmp_ctx, &addr_num, &addrs, total, reply, port); - if (qtype == QTYPE_AAAA && a_num == 0) { + if (qtype == QTYPE_AAAA && addr_num == 0) { /* - * DNS server didn't returned A when asked for AAAA records. + * DNS server didn't returned A when asked for AAAA records, + * and no AAAA record returned either * Most of the server do it, let's ask for A specificaly. */ err = dns_lookup(tmp_ctx, name, QTYPE_A, &reply); @@ -249,7 +250,7 @@ static struct dns_records_container get_a_aaaa_records(TALLOC_CTX *mem_ctx, goto done; } - total = reply_to_addrs(tmp_ctx, &a_num, &addrs, total, + total = reply_to_addrs(tmp_ctx, &addr_num, &addrs, total, reply, port); }