]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
missing pullups:
authorAndreas Gustafsson <source@isc.org>
Fri, 15 Sep 2000 22:56:15 +0000 (22:56 +0000)
committerAndreas Gustafsson <source@isc.org>
Fri, 15 Sep 2000 22:56:15 +0000 (22:56 +0000)
 459.   [bug]           Nslookup processed the set command incorrectly.

 458.   [bug]           Nslookup didn't properly check class and type values.
                        [RT #305]

 457.   [bug]           Dig/host/hslookup didn't properly handle connect
                        timeouts in certain situations, causing an
                        unnecessary warning message to be printed.

bin/dig/dig.c
bin/dig/dighost.c
bin/dig/host.c
bin/dig/nslookup.c

index d8618499e6fecd1a1469b0d80a576082adcdacd1..e29ee14b8ad53e953e585fbf53efbcf10d866d09 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: dig.c,v 1.51.2.7 2000/09/12 23:07:03 explorer Exp $ */
+/* $Id: dig.c,v 1.51.2.8 2000/09/15 22:56:11 gson Exp $ */
 
 #include <config.h>
 #include <stdlib.h>
@@ -46,7 +46,7 @@ extern ISC_LIST(dig_searchlist_t) search_list;
 
 
 extern isc_boolean_t have_ipv6, show_details, specified_source,
-       usesearch, qr;
+       usesearch, qr, ignore;
 extern in_port_t port;
 extern unsigned int timeout;
 extern isc_mem_t *mctx;
@@ -159,6 +159,8 @@ show_usage(void) {
 "                 +[no]search         (Set whether to use searchlist)\n"
 "                 +[no]defname        (Set whether to use default domaon)\n"
 "                 +[no]recursive      (Recursive mode)\n"
+"                 +[no]ignore         (Don't revert to TCP for TC responses.)"
+"\n"
 "                 +[no]aaonly         (Set AA flag in query)\n"
 "                 +[no]adflag         (Set AD flag in query)\n"
 "                 +[no]cdflag         (Set CD flag in query)\n"
@@ -827,6 +829,10 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
                        }
                } else if (strncmp(rv[0], "+nosho", 6) == 0) {
                        short_form = ISC_FALSE;
+               } else if (strncmp(rv[0], "+i", 2) == 0) {
+                       ignore = ISC_TRUE;
+               } else if (strncmp(rv[0], "+noi", 4) == 0) {
+                       ignore = ISC_FALSE;
                } else if (strncmp(rv[0], "+id", 3) == 0) {
                        if (have_host)
                                lookup->identify = ISC_TRUE;
index 59a82effc2ee01fde0fb19d38003586ece4a7ec7..f6aea0ba9577550b33c77e80a6202cc367c9caaa 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: dighost.c,v 1.58.2.10 2000/08/18 20:00:11 gson Exp $ */
+/* $Id: dighost.c,v 1.58.2.11 2000/09/15 22:56:12 gson Exp $ */
 
 /*
  * Notice to programmers:  Do not use this code as an example of how to
@@ -74,7 +74,8 @@ isc_boolean_t
        show_details = ISC_FALSE,
        usesearch = ISC_FALSE,
        qr = ISC_FALSE,
-       is_dst_up = ISC_FALSE;
+       is_dst_up = ISC_FALSE,
+       ignore = ISC_FALSE;
 
 in_port_t port = 53;
 unsigned int timeout = 0;
@@ -1467,6 +1468,14 @@ connect_done(isc_task_t *task, isc_event_t *event) {
 
        query->waiting_connect = ISC_FALSE;
 
+       if (sevent->result == ISC_R_CANCELED) {
+               debug("in cancel handler");
+               query->working = ISC_FALSE;
+               query->waiting_connect = ISC_FALSE;
+               isc_event_free(&event);
+               check_next_lookup(query->lookup);
+               return;
+       }
        if (sevent->result != ISC_R_SUCCESS) {
                debug("buffer allocate connect_timeout");
                result = isc_buffer_allocate(mctx, &b, 256);
@@ -1760,16 +1769,23 @@ recv_done(isc_task_t *task, isc_event_t *event) {
                        hex_dump(b);
                        query->working = ISC_FALSE;
                        query->waiting_connect = ISC_FALSE;
-                       if (!query->lookup->tcp_mode) {
-                               printf(";; Retrying in TCP mode.\n");
-                               n = requeue_lookup(query->lookup, ISC_TRUE);
-                               n->tcp_mode = ISC_TRUE;
-                       }
                        dns_message_destroy(&msg);
                        isc_event_free(&event);
-                       result_bool = cancel_lookup(query->lookup);
+                       cancel_lookup(query->lookup);
                        return;
                }
+               if (((msg->flags & DNS_MESSAGEFLAG_TC) != 0) 
+                   && !query->lookup->tcp_mode && !ignore) {
+                       printf(";; Truncated, retrying in TCP mode.\n");
+                       n = requeue_lookup(query->lookup, ISC_TRUE);
+                       n->tcp_mode = ISC_TRUE;
+                       query->working = ISC_FALSE;
+                       query->waiting_connect = ISC_FALSE;
+                      dns_message_destroy(&msg);
+                      isc_event_free(&event);
+                      cancel_lookup(query->lookup);
+                      return;
+               }
                if (key != NULL) {
                        debug("querysig 2 is %p", query->lookup->querysig);
                        debug("before verify");
index 0dfe7f36540c54d896953a0be0210a70e9037ec9..4f51277c9f0498210ae634e2b4ac23f3ca4cbf0e 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: host.c,v 1.29.2.5 2000/08/22 17:42:45 bwelling Exp $ */
+/* $Id: host.c,v 1.29.2.6 2000/09/15 22:56:14 gson Exp $ */
 
 #include <config.h>
 #include <stdlib.h>
@@ -62,7 +62,8 @@ isc_boolean_t
        short_form = ISC_TRUE,
        filter = ISC_FALSE,
        showallsoa = ISC_FALSE,
-       tcpmode = ISC_FALSE;
+       tcpmode = ISC_FALSE,
+       listed_server = ISC_FALSE;
 
 static const char *opcodetext[] = {
        "QUERY",
@@ -507,6 +508,20 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
                                      ISC_TF(!short_form), query);
                if (result != ISC_R_SUCCESS)
                        return (result);
+       } else {
+               if ((short_form) && (listed_server)) {
+                        printf("Using domain server:\n");
+                        printf("Name: %s\n", query->servname);
+                        result = isc_buffer_allocate(mctx, &b, MXNAME);
+                        check_result(result, "isc_buffer_allocate");
+                        result = isc_sockaddr_totext(&query->sockaddr, b);
+                        check_result(result, "isc_sockaddr_totext");
+                        printf("Address: %.*s\n",
+                               (int)isc_buffer_usedlength(b),
+                               (char*)isc_buffer_base(b));
+                        isc_buffer_free(&b);
+                        printf("Aliases: \n\n");
+                }
        }
        if (! ISC_LIST_EMPTY(msg->sections[DNS_SECTION_AUTHORITY]) &&
            !short_form) {
@@ -626,6 +641,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
                        argv[isc_commandline_index+1], MXNAME-1);
                debug("server is %s", srv->servername);
                ISC_LIST_APPEND(server_list, srv, link);
+               listed_server = ISC_TRUE;
        }
        
        lookup = isc_mem_allocate(mctx, sizeof(struct dig_lookup));
index 4de83274eb1bbbf26e574d061d48db4362230965..f00fc3a0f715be73cc29640c57484bbb98ba2765 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: nslookup.c,v 1.20.2.7 2000/09/05 21:58:09 gson Exp $ */
+/* $Id: nslookup.c,v 1.20.2.8 2000/09/15 22:56:15 gson Exp $ */
 
 #include <config.h>
 
@@ -28,6 +28,7 @@ extern int h_errno;
 #include <dns/rdata.h>
 #include <dns/rdataset.h>
 #include <dns/rdatatype.h>
+#include <dns/rdataclass.h>
 #include <isc/app.h>
 #include <isc/buffer.h>
 #include <isc/commandline.h>
@@ -496,6 +497,16 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
 
        debug ("printmessage()");
 
+       debug ("continuing on with rcode != 0");
+       result = isc_buffer_allocate(mctx, &b, MXNAME);
+       check_result(result, "isc_buffer_allocate");
+       printf("Server:\t\t%s\n", query->servname);
+       result = isc_sockaddr_totext(&query->sockaddr, b);
+       check_result(result, "isc_sockaddr_totext");
+       printf("Address:\t%.*s\n", (int)isc_buffer_usedlength(b),
+              (char*)isc_buffer_base(b));
+       isc_buffer_free(&b);
+       puts("");
        if (msg->rcode != 0) {
                result = isc_buffer_allocate(mctx, &b, MXNAME);
                check_result(result, "isc_buffer_allocate");
@@ -510,16 +521,6 @@ printmessage(dig_query_t *query, dns_message_t *msg, isc_boolean_t headers) {
                debug ("returning with rcode == 0");
                return (ISC_R_SUCCESS);
        }
-       debug ("continuing on with rcode != 0");
-       result = isc_buffer_allocate(mctx, &b, MXNAME);
-       check_result(result, "isc_buffer_allocate");
-       printf("Server:\t\t%s\n", query->servname);
-       result = isc_sockaddr_totext(&query->sockaddr, b);
-       check_result(result, "isc_sockaddr_totext");
-       printf("Address:\t%.*s\n", (int)isc_buffer_usedlength(b),
-              (char*)isc_buffer_base(b));
-       isc_buffer_free(&b);
-       puts("");
        if (!short_form){
                puts ("------------");
                /*              detailheader(query, msg);*/
@@ -585,6 +586,41 @@ show_settings(isc_boolean_t full) {
 
 }
 
+static isc_boolean_t
+testtype(char *typetext) {
+       isc_result_t result;
+       isc_textregion_t tr;
+       dns_rdatatype_t rdtype;
+       
+       tr.base = typetext;
+       tr.length = strlen(typetext);
+       result = dns_rdatatype_fromtext(&rdtype, &tr);
+       if (result == ISC_R_SUCCESS)
+               return (ISC_TRUE);
+       else {
+               printf("unknown query type: %s\n", typetext);
+               return (ISC_FALSE);
+       }
+}
+
+static isc_boolean_t
+testclass(char *typetext) {
+       isc_result_t result;
+       isc_textregion_t tr;
+       dns_rdataclass_t rdclass;
+
+       tr.base = typetext;
+       tr.length = strlen(typetext);
+       result = dns_rdataclass_fromtext(&rdclass, &tr);
+       if (result == ISC_R_SUCCESS) 
+               return (ISC_TRUE);
+       else {
+               printf("unknown query class: %s\n", typetext);
+               return (ISC_FALSE);
+       }
+}
+
+
 static void
 setoption(char *opt) {
        dig_server_t *srv;
@@ -592,19 +628,26 @@ setoption(char *opt) {
        if (strncasecmp(opt,"all",4) == 0) {
                show_settings(ISC_TRUE);
        } else if (strncasecmp(opt, "class=", 6) == 0) {
-               strncpy(defclass, &opt[6], MXRD);
+               if (testclass(&opt[6]))
+                       strncpy(defclass, &opt[6], MXRD);
        } else if (strncasecmp(opt, "cl=", 3) == 0) {
-               strncpy(defclass, &opt[3], MXRD);
+               if (testclass(&opt[3]))
+                       strncpy(defclass, &opt[3], MXRD);
        } else if (strncasecmp(opt, "type=", 5) == 0) {
-               strncpy(deftype, &opt[5], MXRD);
+               if (testtype(&opt[5]))
+                       strncpy(deftype, &opt[5], MXRD);
        } else if (strncasecmp(opt, "ty=", 3) == 0) {
-               strncpy(deftype, &opt[3], MXRD);
+               if (testtype(&opt[3]))
+                       strncpy(deftype, &opt[3], MXRD);
        } else if (strncasecmp(opt, "querytype=", 10) == 0) {
-               strncpy(deftype, &opt[10], MXRD);
+               if (testtype(&opt[10]))
+                       strncpy(deftype, &opt[10], MXRD);
        } else if (strncasecmp(opt, "query=", 6) == 0) {
-               strncpy(deftype, &opt[6], MXRD);
+               if (testtype(&opt[6]))
+                       strncpy(deftype, &opt[6], MXRD);
        } else if (strncasecmp(opt, "qu=", 3) == 0) {
-               strncpy(deftype, &opt[3], MXRD);
+               if (testtype(&opt[3]))
+                       strncpy(deftype, &opt[3], MXRD);
 #if 0
                /* XXXMWS domain= doesn't work now. */
        } else if (strncasecmp(opt, "domain=", 7) == 0) {
@@ -655,8 +698,18 @@ addlookup(char *opt) {
                fatal("Memory allocation failure.");
        lookup->pending = ISC_FALSE;
        strncpy(lookup->textname, opt, MXNAME-1);
-       strncpy (lookup->rttext, deftype, MXNAME);
-       strncpy (lookup->rctext, defclass, MXNAME);
+       if (istype(deftype))
+               strncpy(lookup->rttext, deftype, MXNAME);
+       else {
+               strcpy(lookup->rttext, "a");
+               printf ("unknown query type: %s\n",deftype);
+       }
+       if (isclass(defclass))
+               strncpy(lookup->rctext, defclass, MXNAME);
+       else {
+               strcpy(lookup->rctext, "in");
+               printf ("unknown query class: %s\n",defclass);
+       }
        lookup->namespace[0]=0;
        lookup->sendspace = NULL;
        lookup->sendmsg=NULL;