Fix can't get dns server on macos and ios (#401)

If DNS configuration didn't include search domains on MacOS (or iOS) it would throw an error instead of ignoring.

Fix By: @halx99
pull/406/head
HALX99 4 years ago committed by GitHub
parent fd890e9246
commit 809d5e84f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 23
      src/lib/ares_init.c

@ -1665,17 +1665,18 @@ static int init_by_resolv_conf(ares_channel channel)
int entries = 0;
while ((entries < MAXDNSRCH) && res.dnsrch[entries])
entries++;
channel->domains = ares_malloc(entries * sizeof(char *));
if (!channel->domains) {
status = ARES_ENOMEM;
} else {
int i;
channel->ndomains = entries;
for (i = 0; i < channel->ndomains; ++i) {
channel->domains[i] = ares_strdup(res.dnsrch[i]);
if (!channel->domains[i])
status = ARES_ENOMEM;
if(entries) {
channel->domains = ares_malloc(entries * sizeof(char *));
if (!channel->domains) {
status = ARES_ENOMEM;
} else {
int i;
channel->ndomains = entries;
for (i = 0; i < channel->ndomains; ++i) {
channel->domains[i] = ares_strdup(res.dnsrch[i]);
if (!channel->domains[i])
status = ARES_ENOMEM;
}
}
}
}

Loading…
Cancel
Save