]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
3962. [bug] 'dig +topdown +trace +sigchase' address unhandled error ...
authorMark Andrews <marka@isc.org>
Wed, 1 Oct 2014 00:01:54 +0000 (10:01 +1000)
committerMark Andrews <marka@isc.org>
Wed, 1 Oct 2014 00:01:54 +0000 (10:01 +1000)
CHANGES
bin/dig/dighost.c

diff --git a/CHANGES b/CHANGES
index 9b92fbaf3dd37c367f1a84d7218ef491d45e1bb3..a02a16a515eb3b9c97467cb9908e99d578c7d6e9 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+3962.  [bug]           'dig +topdown +trace +sigchase' address unhandled error
+                       conditions. [RT #34663]
+
 3961.  [bug]           Forwarding of SIG(0) signed UPDATE messages failed with
                        BADSIG.  [RT #37216]
 
index c99dcfc5671cb3779a6c845d53a393024bef3d65..aeded9e42778e8d10d3ad607ab0424ca37a8c057 100644 (file)
@@ -56,6 +56,7 @@
 #include <dns/log.h>
 #include <dns/message.h>
 #include <dns/name.h>
+#include <dns/rcode.h>
 #include <dns/rdata.h>
 #include <dns/rdataclass.h>
 #include <dns/rdatalist.h>
@@ -4489,6 +4490,9 @@ chase_scanname_section(dns_message_t *msg, dns_name_t *name,
        dns_rdataset_t *rdataset;
        dns_name_t *msg_name = NULL;
 
+       if (msg->counts[section] == 0)
+               return (NULL);
+
        do {
                dns_message_currentname(msg, section, &msg_name);
                if (dns_name_compare(msg_name, name) == 0) {
@@ -5297,6 +5301,20 @@ sigchase_td(dns_message_t *msg)
        isc_boolean_t have_answer = ISC_FALSE;
        isc_boolean_t true = ISC_TRUE;
 
+       if (msg->rcode != dns_rcode_noerror &&
+           msg->rcode != dns_rcode_nxdomain) {
+               char buf[20];
+               isc_buffer_t b;
+
+               isc_buffer_init(&b, buf, sizeof(buf));
+               result = dns_rcode_totext(msg->rcode, &b);
+               check_result(result, "dns_rcode_totext failed");
+               printf("error response code %.*s\n", 
+                      (int)isc_buffer_usedlength(&b), buf);
+               error_message = msg;
+               return; 
+       }
+
        if ((result = dns_message_firstname(msg, DNS_SECTION_ANSWER))
            == ISC_R_SUCCESS) {
                dns_message_currentname(msg, DNS_SECTION_ANSWER, &name);
@@ -5309,10 +5327,13 @@ sigchase_td(dns_message_t *msg)
                if (!current_lookup->trace_root_sigchase) {
                        result = dns_message_firstname(msg,
                                                       DNS_SECTION_AUTHORITY);
-                       if (result == ISC_R_SUCCESS)
-                               dns_message_currentname(msg,
-                                                       DNS_SECTION_AUTHORITY,
-                                                       &name);
+                       if (result != ISC_R_SUCCESS) {
+                               printf("no answer or authority section\n");
+                               error_message = msg;
+                               return;
+                       }
+                       dns_message_currentname(msg, DNS_SECTION_AUTHORITY,
+                                               &name);
                        chase_nsrdataset
                                = chase_scanname_section(msg, name,
                                                         dns_rdatatype_ns,
@@ -5322,7 +5343,7 @@ sigchase_td(dns_message_t *msg)
                        if (chase_nsrdataset != NULL) {
                                have_delegation_ns = ISC_TRUE;
                                printf("no response but there is a delegation"
-                                      " in authority section:");
+                                      " in authority section: ");
                                dns_name_print(name, stdout);
                                printf("\n");
                        } else {