From: Matthijs Mekking Date: Tue, 26 Feb 2019 14:55:29 +0000 (+0100) Subject: Fix nxdomain-redirect assertion failure X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f6bc840cc5fce61a2300201cddc11dce26faa16;p=thirdparty%2Fbind9.git Fix nxdomain-redirect assertion failure - Always set is_zonep in query_getdb; previously it was only set if result was ISC_R_SUCCESS or ISC_R_NOTFOUND. - Don't reset is_zone for redirect. - Style cleanup. (cherry picked from commit 3352270bdbbb39b167072aa282c6b310ffd96a7d) (cherry picked from commit e2500c60a0a764f35116e57b8d22f3109e97f75b) (cherry picked from commit 4f00c86ece0ee0f46bd1aff4e531459dd6307f6d) --- diff --git a/lib/ns/query.c b/lib/ns/query.c index 09d8823ec66..6bf20ca7e60 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -1472,7 +1472,6 @@ query_getdb(ns_client_t *client, dns_name_t *name, dns_rdatatype_t qtype, dns_dbversion_t **versionp, bool *is_zonep) { isc_result_t result; - isc_result_t tresult; unsigned int namelabels; unsigned int zonelabels; @@ -1489,8 +1488,9 @@ query_getdb(ns_client_t *client, dns_name_t *name, dns_rdatatype_t qtype, dbp, versionp); /* See how many labels are in the zone's name. */ - if (result == ISC_R_SUCCESS && zone != NULL) + if (result == ISC_R_SUCCESS && zone != NULL) { zonelabels = dns_name_countlabels(dns_zone_getorigin(zone)); + } /* * If # zone labels < # name labels, try to find an even better match @@ -1557,8 +1557,11 @@ query_getdb(ns_client_t *client, dns_name_t *name, dns_rdatatype_t qtype, * If neither attempt above succeeded, return the cache instead */ *is_zonep = true; - } else if (result == ISC_R_NOTFOUND) { - result = query_getcachedb(client, name, qtype, dbp, options); + } else { + if (result == ISC_R_NOTFOUND) { + result = query_getcachedb(client, name, qtype, dbp, + options); + } *is_zonep = false; } return (result); @@ -4792,11 +4795,13 @@ redirect2(ns_client_t *client, dns_name_t *name, dns_rdataset_t *rdataset, CTRACE(ISC_LOG_DEBUG(3), "redirect2"); - if (client->view->redirectzone == NULL) + if (client->view->redirectzone == NULL) { return (ISC_R_NOTFOUND); + } - if (dns_name_issubdomain(name, client->view->redirectzone)) + if (dns_name_issubdomain(name, client->view->redirectzone)) { return (ISC_R_NOTFOUND); + } found = dns_fixedname_initname(&fixed); dns_rdataset_init(&trdataset); @@ -4804,8 +4809,9 @@ redirect2(ns_client_t *client, dns_name_t *name, dns_rdataset_t *rdataset, dns_clientinfomethods_init(&cm, ns_client_sourceip); dns_clientinfo_init(&ci, client, NULL); - if (WANTDNSSEC(client) && dns_db_iszone(*dbp) && dns_db_issecure(*dbp)) + if (WANTDNSSEC(client) && dns_db_iszone(*dbp) && dns_db_issecure(*dbp)) { return (ISC_R_NOTFOUND); + } if (WANTDNSSEC(client) && dns_rdataset_isassociated(rdataset)) { if (rdataset->trust == dns_trust_secure) @@ -4842,16 +4848,19 @@ redirect2(ns_client_t *client, dns_name_t *name, dns_rdataset_t *rdataset, redirectname, NULL); if (result != ISC_R_SUCCESS) return (ISC_R_NOTFOUND); - } else + } else { dns_name_copy(redirectname, client->view->redirectzone, NULL); + } options = 0; result = query_getdb(client, redirectname, qtype, options, &zone, &db, &version, &is_zone); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { return (ISC_R_NOTFOUND); - if (zone != NULL) + } + if (zone != NULL) { dns_zone_detach(&zone); + } /* * Lookup the requested data in the redirect zone. @@ -5500,7 +5509,6 @@ query_lookup(query_ctx_t *qctx) { return (query_done(qctx)); } } - return (query_gotanswer(qctx, result)); } @@ -5890,7 +5898,6 @@ query_resume(query_ctx_t *qctx) { RESTORE(qctx->zone, qctx->client->query.redirect.zone); qctx->authoritative = qctx->client->query.redirect.authoritative; - qctx->is_zone = qctx->client->query.redirect.is_zone; /* * Free resources used while recursing. @@ -5997,7 +6004,6 @@ query_resume(query_ctx_t *qctx) { ISC_EVENT_PTR(&qctx->event), &qctx->event); } else if (REDIRECT(qctx->client)) { result = qctx->client->query.redirect.result; - qctx->is_zone = qctx->client->query.redirect.is_zone; } else { result = qctx->event->result; }