]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add +besteffort option to dig (on by default) which will cause the
authorMichael Sawyer <source@isc.org>
Fri, 13 Oct 2000 17:54:00 +0000 (17:54 +0000)
committerMichael Sawyer <source@isc.org>
Fri, 13 Oct 2000 17:54:00 +0000 (17:54 +0000)
message parser to accept somewhat malformed packets.

bin/dig/dig.c
bin/dig/dighost.c
bin/dig/include/dig/dig.h

index fb5cf0e5833dbcdf795a2aed7800c7f9a8d99b9e..dc34a05bb363d99d8689919605e2ae11335176a0 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: dig.c,v 1.111 2000/10/11 17:44:00 mws Exp $ */
+/* $Id: dig.c,v 1.112 2000/10/13 17:53:57 mws Exp $ */
 
 #include <config.h>
 #include <stdlib.h>
@@ -161,6 +161,7 @@ show_usage(void) {
 "                 +[no]ignore         (Don't revert to TCP for TC responses.)"
 "\n"
 "                 +[no]fail           (Don't try next server on SERVFAIL)\n"
+"                 +[no]besteffort     (Try and parse even illegal messages)\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"
@@ -638,16 +639,25 @@ plus_option(char *option, isc_boolean_t is_batchfile,
                        goto invalid_option;
                }
                break;
-       case 'b': /* bufsize */
-               if (value == NULL)
-                       goto need_value;
-               if (!state)
+       case 'b':
+               switch (tolower(cmd[1])) {
+               case 'e':/* besteffort */
+                       lookup->besteffort = state;
+                       break;
+               case 'u':/* bufsize */
+                       if (value == NULL)
+                               goto need_value;
+                       if (!state)
+                               goto invalid_option;
+                       lookup->udpsize = atoi(value);
+                       if (lookup->udpsize <= 0)
+                               lookup->udpsize = 0;
+                       if (lookup->udpsize > COMMSIZE)
+                               lookup->udpsize = COMMSIZE;
+                       break;
+               default:
                        goto invalid_option;
-               lookup->udpsize = atoi(value);
-               if (lookup->udpsize <= 0)
-                       lookup->udpsize = 0;
-               if (lookup->udpsize > COMMSIZE)
-                       lookup->udpsize = COMMSIZE;
+               }
                break;
        case 'c':
                switch (tolower(cmd[1])) {
index 9871e928520fdec3ff848b90593cc864d98b35ff..eac7dc65acea31959041542ae5d8cf9427b00e03 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: dighost.c,v 1.143 2000/10/12 01:16:12 bwelling Exp $ */
+/* $Id: dighost.c,v 1.144 2000/10/13 17:53:58 mws Exp $ */
 
 /*
  * Notice to programmers:  Do not use this code as an example of how to
@@ -301,6 +301,7 @@ make_empty_lookup(void) {
        looknew->identify = ISC_FALSE;
        looknew->ignore = ISC_FALSE;
        looknew->servfail_stops = ISC_FALSE;
+       looknew->besteffort = ISC_TRUE;
        looknew->udpsize = 0;
        looknew->recurse = ISC_TRUE;
        looknew->aaonly = ISC_FALSE;
@@ -357,6 +358,7 @@ clone_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
        looknew->identify = lookold->identify;
        looknew->ignore = lookold->ignore;
        looknew->servfail_stops = lookold->servfail_stops;
+       looknew->besteffort = lookold->besteffort;
        looknew->udpsize = lookold->udpsize;
        looknew->recurse = lookold->recurse;
         looknew->aaonly = lookold->aaonly;
@@ -2238,9 +2240,15 @@ recv_done(isc_task_t *task, isc_event_t *event) {
                        l->msgcounter++;
                }
                debug("before parse starts");
-               result = dns_message_parse(msg, b,
+               if (l->besteffort)
+                       result = dns_message_parse(msg, b,
+                                          DNS_MESSAGEPARSE_PRESERVEORDER
+                                          |DNS_MESSAGEPARSE_BESTEFFORT);
+               else
+                       result = dns_message_parse(msg, b,
                                           DNS_MESSAGEPARSE_PRESERVEORDER);
-               if (result != ISC_R_SUCCESS) {
+               if (result != ISC_R_SUCCESS && 
+                   result != DNS_R_RECOVERABLE ) {
                        printf(";; Got bad packet: %s\n",
                               dns_result_totext(result));
                        hex_dump(b);
@@ -2253,6 +2261,9 @@ recv_done(isc_task_t *task, isc_event_t *event) {
                        UNLOCK_LOOKUP;
                        return;
                }
+               if (result == DNS_R_RECOVERABLE)
+                       printf(";; Warning: Message parser reports malformed "
+                              "message packet.\n");
                if (((msg->flags & DNS_MESSAGEFLAG_TC) != 0) 
                    && ! l->ignore && !l->tcp_mode) {
                        printf(";; Truncated, retrying in TCP mode.\n");
index a7ac8a1d635595cb08d18feecb5eb1fff891bf48..98b87162d9d3407ad4fe7b3e7fa782c65f73cf8b 100644 (file)
@@ -15,7 +15,7 @@
  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: dig.h,v 1.52 2000/10/11 17:44:03 mws Exp $ */
+/* $Id: dig.h,v 1.53 2000/10/13 17:54:00 mws Exp $ */
 
 #ifndef DIG_H
 #define DIG_H
@@ -95,7 +95,8 @@ struct dig_lookup {
                section_authority,
                section_additional,
                servfail_stops,
-               new_search;
+               new_search,
+               besteffort;
        char textname[MXNAME]; /* Name we're going to be looking up */
        char cmdline[MXNAME];
        dns_rdatatype_t rdtype;