From 6f12e3ca45c560f2f7c8eaa037e84eeab82f9475 Mon Sep 17 00:00:00 2001 From: Andreas Gustafsson Date: Mon, 24 Jul 2000 20:10:26 +0000 Subject: [PATCH] Restored the "done" variable removed in 1.150 and made the result code check after the loop deal with ISC_R_SUCCESS instead. The previous fix had the side effect of keeping multiple answers to non-ANY queries, causing assertion failures in cache_name() which is not prepared to deal with this situation --- lib/dns/resolver.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 9bb3380b9a..edff8c49b1 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -15,7 +15,7 @@ * SOFTWARE. */ -/* $Id: resolver.c,v 1.150 2000/07/19 23:19:05 gson Exp $ */ +/* $Id: resolver.c,v 1.151 2000/07/24 20:10:26 gson Exp $ */ #include @@ -3286,7 +3286,7 @@ answer_response(fetchctx_t *fctx) { qname = &fctx->name; type = fctx->type; result = dns_message_firstname(message, DNS_SECTION_ANSWER); - while (result == ISC_R_SUCCESS) { + while (!done && result == ISC_R_SUCCESS) { name = NULL; dns_message_currentname(message, DNS_SECTION_ANSWER, &name); external = ISC_TF(!dns_name_issubdomain(name, &fctx->domain)); @@ -3297,12 +3297,20 @@ answer_response(fetchctx_t *fctx) { found = ISC_FALSE; want_chaining = ISC_FALSE; aflag = 0; - if (rdataset->type == type || - type == dns_rdatatype_any) { + if (rdataset->type == type) { /* * We've found an ordinary answer. */ found = ISC_TRUE; + done = ISC_TRUE; + aflag = DNS_RDATASETATTR_ANSWER; + } else if (type == dns_rdatatype_any) { + /* + * We've found an answer matching + * an ANY query. There may be + * more. + */ + found = ISC_TRUE; aflag = DNS_RDATASETATTR_ANSWER; } else if (rdataset->type == dns_rdatatype_sig && rdataset->covers == type) { @@ -3497,7 +3505,9 @@ answer_response(fetchctx_t *fctx) { } result = dns_message_nextname(message, DNS_SECTION_ANSWER); } - if (result != ISC_R_NOMORE) + if (result == ISC_R_NOMORE) + result = ISC_R_SUCCESS; + if (result != ISC_R_SUCCESS) return (result); /* @@ -3584,10 +3594,10 @@ answer_response(fetchctx_t *fctx) { } result = dns_message_nextname(message, DNS_SECTION_AUTHORITY); } - if (result != ISC_R_NOMORE) - return (result); + if (result == ISC_R_NOMORE) + result = ISC_R_SUCCESS; - return (ISC_R_SUCCESS); + return (result); } static void