From: Mark Andrews Date: Thu, 13 Aug 2009 04:33:51 +0000 (+0000) Subject: 2649. [bug] Set the domain for forward only zones. [RT #19944] X-Git-Tag: v9.7.0a3~94 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=bcd0cbfdae6729c48894501b6bcddc972feda67f;p=thirdparty%2Fbind9.git 2649. [bug] Set the domain for forward only zones. [RT #19944] --- diff --git a/CHANGES b/CHANGES index 6d333dc3b42..b3ce6cbf1dc 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ +2649. [bug] Set the domain for forward only zones. [RT #19944] + 2648. [port] win32: isc_time_seconds() was broken. [RT #19900] 2647. [bug] Remove unnecessary SOA updates when a new KSK is diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 888b15956ea..3bec9adb056 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: resolver.c,v 1.403 2009/07/13 06:24:27 marka Exp $ */ +/* $Id: resolver.c,v 1.404 2009/08/13 04:33:51 marka Exp $ */ /*! \file */ @@ -2530,6 +2530,16 @@ findname(fetchctx_t *fctx, dns_name_t *name, in_port_t port, } } +static isc_boolean_t +isstrictsubdomain(dns_name_t *name1, dns_name_t *name2) { + int order; + unsigned int nlabels; + dns_namereln_t namereln; + + namereln = dns_name_fullcompare(name1, name2, &order, &nlabels); + return (ISC_TF(namereln == dns_namereln_subdomain)); +} + static isc_result_t fctx_getaddresses(fetchctx_t *fctx) { dns_rdata_t rdata = DNS_RDATA_INIT; @@ -2575,6 +2585,8 @@ fctx_getaddresses(fetchctx_t *fctx) { dns_name_t *name = &fctx->name; dns_name_t suffix; unsigned int labels; + dns_fixedname_t fixed; + dns_name_t *domain; /* * DS records are found in the parent server. @@ -2587,11 +2599,26 @@ fctx_getaddresses(fetchctx_t *fctx) { dns_name_getlabelsequence(name, 1, labels - 1, &suffix); name = &suffix; } - result = dns_fwdtable_find(fctx->res->view->fwdtable, name, - &forwarders); + + dns_fixedname_init(&fixed); + domain = dns_fixedname_name(&fixed); + result = dns_fwdtable_find2(fctx->res->view->fwdtable, name, + domain, &forwarders); if (result == ISC_R_SUCCESS) { sa = ISC_LIST_HEAD(forwarders->addrs); fctx->fwdpolicy = forwarders->fwdpolicy; + if (fctx->fwdpolicy == dns_fwdpolicy_only && + isstrictsubdomain(domain, &fctx->domain)) { + isc_mem_t *mctx; + + mctx = res->buckets[fctx->bucketnum].mctx; + dns_name_free(&fctx->domain, mctx); + dns_name_init(&fctx->domain, NULL); + result = dns_name_dup(domain, mctx, + &fctx->domain); + if (result != ISC_R_SUCCESS) + return (result); + } } }