From: Mark Andrews Date: Thu, 13 Aug 2009 04:54:21 +0000 (+0000) Subject: 2649. [bug] Set the domain for forward only zones. [RT #19944] X-Git-Tag: v9.5.2b1~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c199662ea28a13fbd64f0b6f7dae9745ae25c0d6;p=thirdparty%2Fbind9.git 2649. [bug] Set the domain for forward only zones. [RT #19944] --- diff --git a/CHANGES b/CHANGES index 941b0db3aac..f9a5e43d45e 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] 2646. [bug] Incorrect cleanup on error in socket.c. [RT #19987] diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index cdb1475544d..1441f61dba1 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: resolver.c,v 1.355.12.43 2009/07/13 06:33:11 marka Exp $ */ +/* $Id: resolver.c,v 1.355.12.44 2009/08/13 04:54:21 marka Exp $ */ /*! \file */ @@ -2464,6 +2464,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; @@ -2509,6 +2519,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. @@ -2521,11 +2533,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); + } } }