From 1fc26319b5d69d19a7a31c8d0ab1afc2beef0c41 Mon Sep 17 00:00:00 2001 From: Andreas Gustafsson Date: Wed, 6 Sep 2000 18:41:22 +0000 Subject: [PATCH] 423. [bug] When responding to a recusive query, errors that occur after following a CNAME should cause the query to fail. [RT #274] --- CHANGES | 4 ++++ bin/named/query.c | 19 +++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index a06a8afdf2..c155580143 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,8 @@ + 423. [bug] When responding to a recusive query, errors that occur + after following a CNAME should cause the query to fail. + [RT #274] + 422. [func] get rid of isc_random_t, and make isc_random_get() and isc_random_jitter() use rand() internally instead of local state. Note that isc_random_*() diff --git a/bin/named/query.c b/bin/named/query.c index 788c49975c..9d94d8b9c6 100644 --- a/bin/named/query.c +++ b/bin/named/query.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: query.c,v 1.127 2000/08/26 23:22:36 explorer Exp $ */ +/* $Id: query.c,v 1.128 2000/09/06 18:41:22 gson Exp $ */ #include @@ -53,6 +53,8 @@ NS_QUERYATTR_RECURSING) != 0) #define CACHEGLUEOK(c) (((c)->query.attributes & \ NS_QUERYATTR_CACHEGLUEOK) != 0) +#define WANTRECURSION(c) (((c)->query.attributes & \ + NS_QUERYATTR_WANTRECURSION) != 0) #if 0 #define CTRACE(m) isc_log_write(ns_g_lctx, \ @@ -2885,9 +2887,15 @@ query_find(ns_client_t *client, dns_fetchevent_t *event) { goto restart; } - if (eresult != ISC_R_SUCCESS && !PARTIALANSWER(client)) { - ns_client_error(client, eresult); - ns_client_detach(&client); + if (eresult != ISC_R_SUCCESS && + (!PARTIALANSWER(client) || WANTRECURSION(client))) { + /* + * If we don't have any answer to give the client, + * or if the client requested recursion and thus wanted + * the complete answer, send an error response. + */ + ns_client_error(client, eresult); + ns_client_detach(&client); } else if (!RECURSING(client)) { /* * We are done. Make a final tweak to the AA bit if the @@ -2952,6 +2960,9 @@ ns_query_start(ns_client_t *client) { */ client->next = query_next; + if ((message->flags & DNS_MESSAGEFLAG_RD) != 0) + client->query.attributes |= NS_QUERYATTR_WANTRECURSION; + if ((client->view->cachedb == NULL) || (!client->view->additionalfromcache)) { /*