From 3242899a56da9c245956979d5be9c92b2cf0ee24 Mon Sep 17 00:00:00 2001 From: Andreas Gustafsson Date: Sat, 28 Apr 2001 00:21:30 +0000 Subject: [PATCH] 818. [bug] Certain pathological responses to ANY queries could cause an assertion failure. [RT #1218] --- CHANGES | 4 ++++ bin/named/query.c | 29 +++++++++++++++-------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/CHANGES b/CHANGES index 97ea31b32b..57ff12ff3e 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ + + 818. [bug] Certain pathological responses to ANY queries could + cause an assertion failure. [RT #1218] + 817. [func] Adjust timeouts for dialup zone queries. 816. [func] Report potential problems with log file accessibility diff --git a/bin/named/query.c b/bin/named/query.c index 8c878c4269..cd93390786 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.193 2001/04/09 21:16:47 gson Exp $ */ +/* $Id: query.c,v 1.194 2001/04/28 00:21:23 gson Exp $ */ #include @@ -3083,20 +3083,24 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype) * cleanup fname even though we're using it! */ query_keepname(client, fname, dbuf); + tname = fname; result = dns_rdatasetiter_first(rdsiter); while (result == ISC_R_SUCCESS) { dns_rdatasetiter_current(rdsiter, rdataset); if ((qtype == dns_rdatatype_any || rdataset->type == qtype) && rdataset->type != 0) { - tname = fname; - query_addrrset(client, &tname, &rdataset, NULL, + query_addrrset(client, + fname != NULL ? &fname : &tname, + &rdataset, NULL, NULL, DNS_SECTION_ANSWER); n++; + INSIST(tname != NULL); /* - * We shouldn't ever fail to add 'rdataset' - * because it's already in the answer. + * rdataset is non-NULL only in certain pathological + * cases involving DNAMEs. */ - INSIST(rdataset == NULL); + if (rdataset != NULL) + query_putrdataset(client, &rdataset); rdataset = query_newrdataset(client); if (rdataset == NULL) break; @@ -3108,17 +3112,14 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype) } result = dns_rdatasetiter_next(rdsiter); } - if (n > 0) { - /* - * As mentioned above, we must now clear fname - * since we're using it. - */ - fname = NULL; - } else { + + if (fname != NULL) + dns_message_puttempname(client->message, &fname); + + if (n == 0) { /* * We didn't match any rdatasets. */ - dns_message_puttempname(client->message, &fname); if (qtype == dns_rdatatype_sig && result == ISC_R_NOMORE) { /*