UndernetIRC / ircu2

Undernet IRC Daemon
Other
51 stars 20 forks source link

CNAME handling is wrong in stub resolver #17

Open entrope opened 2 years ago

entrope commented 2 years ago

CNAME handling is wrong, according to RFC 1034:

CNAME RRs cause special action in DNS software. When a name server fails to find a desired RR in the resource set associated with the domain name, it checks to see if the resource set consists of a CNAME record with a matching class. If so, the name server includes the CNAME record in the response and restarts the query at the domain name specified in the data field of the CNAME record. The one exception to this rule is that queries which match the CNAME type are not restarted.

ircu2's current behavior causes hostname resolutions to fail when performing a PTR lookup that gets a CNAME response.

entrope commented 2 years ago

On the other hand, RFC 2181 clarifies:

The label that is being looked up for a PTR value might have a CNAME record. That is, it might be an alias. The value of that CNAME RR, if not another alias, which it should not be, will give the location where the PTR record is found. That record gives the result of the PTR type lookup. This final result, the value of the PTR RR, is the label which must not be an alias.

This implies that chasing the CNAME should provide a PTR record next, in which case ircu2's behavior should be right.