Subject: CNAME ordering in ares_parse_a_reply()

CNAME ordering in ares_parse_a_reply()

From: James deBoer <deboer_at_google.com>
Date: Thu, 4 Sep 2008 19:05:54 -0700

Hello,

I am using c-ares to resolve host names from a server which returns
CNAME records after A records.

For example, a request for lion.domain would return:

cat.domain. IN A 1.2.3.4
lion.domain. IN CNAME cat.domain.

This order is opposite to BIND, which always returns CNAME records
first. I haven't found any documentation that specifies a record
order, but I haven't read all the RFCs closely either.

Currently, ares_parse_a_reply() makes a single pass over the DNS
reply. By the time it follows the CNAME pointer, it has missed the
relevant A record.

I have a patch that adds an additional pass to ares_parse_a_reply()
which resolves the CNAME chain before examining the A records. This
change allows c-ares to resolve lion.domain. Is this the correct
approach, or are these upside-down replies invalid?

Thanks,
James.
Received on 2008-09-05