]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Do not treat a referral with a non-empty ANSWER section as an error
authorMichał Kępień <michal@isc.org>
Wed, 22 Aug 2018 08:12:53 +0000 (10:12 +0200)
committerMichał Kępień <michal@isc.org>
Wed, 22 Aug 2018 08:14:37 +0000 (10:14 +0200)
As part of resquery_response() refactoring [1], a goto statement was
replaced [2] with a call to a new function - originally called
rctx_delegation(), now folded into rctx_answer_none() - extracted from
existing code.  However, one call site of that refactored function does
not reset the "result" variable, causing a referral with a non-empty
ANSWER section to be inadvertently treated as an error, which prevents
resolution of names reliant on servers sending such responses.  Fix by
resetting the "result" variable to ISC_R_SUCCESS when a response
containing a non-empty ANSWER section can be treated as a delegation.

[1] see RT #45362

[2] see commit e1380a16741a3b4a57e54d7a9ce09dd12691522f

bin/tests/system/resolver/ans2/ans.pl
bin/tests/system/resolver/ans3/ans.pl
bin/tests/system/resolver/tests.sh
lib/dns/resolver.c

index 79bb10205c8bf606fb9b4f38d78cc0fa1fb4e106..9d5251e8b4c24e5d49531addadf50a839ee75849 100644 (file)
@@ -107,6 +107,10 @@ for (;;) {
                # expected to be accepted regardless of the filter setting.
                $packet->push("authority", new Net::DNS::RR("sub.example.org 300 NS ns.sub.example.org"));
                $packet->push("additional", new Net::DNS::RR("ns.sub.example.org 300 A 10.53.0.3"));
+       } elsif ($qname =~ /glue-in-answer\.example\.org/) {
+               $packet->push("answer", new Net::DNS::RR("ns.glue-in-answer.example.org 300 A 10.53.0.3"));
+               $packet->push("authority", new Net::DNS::RR("glue-in-answer.example.org 300 NS ns.glue-in-answer.example.org"));
+               $packet->push("additional", new Net::DNS::RR("ns.glue-in-answer.example.org 300 A 10.53.0.3"));
        } elsif ($qname =~ /\.broken/ || $qname =~ /^broken/) {
                # Delegation to broken TLD.
                $packet->push("authority", new Net::DNS::RR("broken 300 NS ns.broken"));
index 972ca5c8de5a75664dc4da4ef0c202a2a3960acf..097ced4b2dd1c2b9bb2852795fe7e341febae9ab 100644 (file)
@@ -107,6 +107,8 @@ for (;;) {
        } elsif ($qname eq "www.ok.sub.example.org") {
                $packet->push("answer",
                              new Net::DNS::RR($qname . " 300 A 192.0.2.1"));
+       } elsif ($qname eq "foo.glue-in-answer.example.org") {
+               $packet->push("answer", new Net::DNS::RR($qname . " 300 A 192.0.2.1"));
        } else {
                $packet->push("answer", new Net::DNS::RR("www.example.com 300 A 1.2.3.4"));
        }
index 12d2819e30017f6115453863e08640afad0239ee..2bea476f1be0b96e25740a6606132163f130ed8e 100755 (executable)
@@ -247,6 +247,15 @@ if [ -x ${RESOLVE} ] ; then
     status=`expr $status + $ret`
 fi
 
+n=`expr $n + 1`
+echo_i "check that the resolver accepts a referral response with a non-empty ANSWER section ($n)"
+ret=0
+$DIG $DIGOPTS @10.53.0.1 foo.glue-in-answer.example.org. A > dig.ns1.out.${n} || ret=1
+grep "status: NOERROR" dig.ns1.out.${n} > /dev/null || ret=1
+grep "foo.glue-in-answer.example.org.*192.0.2.1" dig.ns1.out.${n} > /dev/null || ret=1
+if [ $ret != 0 ]; then echo_i "failed"; fi
+status=`expr $status + $ret`
+
 n=`expr $n + 1`
 echo_i "RT21594 regression test check setup ($n)"
 ret=0
index a71ece63014cdcf7e05a85667d2418446f6cc01e..cbc1aa8348a50f52b54e5b481cfb32de3f9a3a8a 100644 (file)
@@ -7881,7 +7881,9 @@ rctx_answer(respctx_t *rctx) {
                        }
                }
 
-               if (result != DNS_R_DELEGATION) {
+               if (result == DNS_R_DELEGATION) {
+                       result = ISC_R_SUCCESS;
+               } else {
                        /*
                         * At this point, AA is not set, the response
                         * is not a referral, and the server is not a