diff --git a/CHANGES b/CHANGES index 39cd65195d..79b885a920 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ + 333. [bug] The resolver incorrectly accepted referrals to + subdomains of the query domain, causing an + assertion failure. + 332. [func] New function dns_name_reset(). 331. [bug] Only log "recursion denied" if RD is set. (RT #178) diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index d5681da77a..b67ba939da 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: resolver.c,v 1.147 2000/07/14 00:37:27 gson Exp $ */ +/* $Id: resolver.c,v 1.148 2000/07/15 01:02:25 gson Exp $ */ #include @@ -2982,6 +2982,31 @@ dname_target(dns_rdataset_t *rdataset, dns_name_t *qname, dns_name_t *oname, return (dns_name_concatenate(dname, &tname, dname, NULL)); } +/* XXXAG should be public function in name.c */ + +static isc_boolean_t +dns_name_ispropersubdomain(const dns_name_t *name1, const dns_name_t *name2) { + int order; + unsigned int nlabels, nbits; + dns_namereln_t namereln; + + /* + * Is 'name1' a proper subdomain of 'name2'? + * + * Note: It makes no sense for one of the names to be relative and the + * other absolute. If both names are relative, then to be meaningfully + * compared the caller must ensure that they are both relative to the + * same domain. + */ + + namereln = dns_name_fullcompare(name1, name2, &order, &nlabels, + &nbits); + if (namereln == dns_namereln_subdomain) + return (ISC_TRUE); + + return (ISC_FALSE); +} + static isc_result_t noanswer_response(fetchctx_t *fctx, dns_name_t *oqname) { isc_result_t result; @@ -3154,6 +3179,17 @@ noanswer_response(fetchctx_t *fctx, dns_name_t *oqname) { */ if (dns_name_equal(ns_name, &fctx->domain)) return (DNS_R_FORMERR); + + /* + * If the referral name is below the query name, + * we are making too much progress, overshooting + * the target. Consider the responder insane. + */ + if (dns_name_ispropersubdomain(ns_name, &fctx->name)) { + FCTXTRACE("referral name below query name"); + return (DNS_R_FORMERR); + } + /* * Mark any additional data related to this rdataset. * It's important that we do this before we change the