summaryrefslogtreecommitdiff
path: root/ares_gethostbyname.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2008-07-03 11:32:35 +0000
committerDaniel Stenberg <daniel@haxx.se>2008-07-03 11:32:35 +0000
commit93e7573628f717a9615d94b9ef76f6365b664eef (patch)
treed9e6eaa5fde2500eb586c8d02b0310260f11c119 /ares_gethostbyname.c
parentdaa25aa705a34db5e5b5a2c3c527160c41b95fc2 (diff)
downloadc-ares-93e7573628f717a9615d94b9ef76f6365b664eef.tar.gz
c-ares-93e7573628f717a9615d94b9ef76f6365b664eef.tar.bz2
c-ares-93e7573628f717a9615d94b9ef76f6365b664eef.zip
- Phil Blundell: If you ask ares_gethostbyname() to do an AF_INET6 lookup and
the target host has only A records, it automatically falls back to an AF_INET lookup and gives you the A results. However, if the target host has a CNAME record, this behaviour is defeated since the original query does return some data even though ares_parse_aaa_reply() doesn't consider it relevant. Here's a small patch to make it behave the same with and without the CNAME.
Diffstat (limited to 'ares_gethostbyname.c')
-rw-r--r--ares_gethostbyname.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/ares_gethostbyname.c b/ares_gethostbyname.c
index d737b41..1e7e158 100644
--- a/ares_gethostbyname.c
+++ b/ares_gethostbyname.c
@@ -176,6 +176,15 @@ static void host_callback(void *arg, int status, int timeouts,
else if (hquery->family == AF_INET6)
{
status = ares_parse_aaaa_reply(abuf, alen, &host, NULL, NULL);
+ if (status == ARES_ENODATA)
+ {
+ /* The query returned something (e.g. CNAME) but there were no
+ AAAA records. Try looking up A instead. */
+ hquery->family = AF_INET;
+ ares_search(hquery->channel, hquery->name, C_IN, T_A, host_callback,
+ hquery);
+ return;
+ }
if (host && channel->nsort)
sort6_addresses(host, channel->sortlist, channel->nsort);
}