From: Michael Sawyer Date: Fri, 13 Oct 2000 17:54:00 +0000 (+0000) Subject: Add +besteffort option to dig (on by default) which will cause the X-Git-Tag: v9.0.1^4~49 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=233514c1da6c51f056dad8bd2c8a82deea5ce3ef;p=thirdparty%2Fbind9.git Add +besteffort option to dig (on by default) which will cause the message parser to accept somewhat malformed packets. --- diff --git a/bin/dig/dig.c b/bin/dig/dig.c index fb5cf0e5833..dc34a05bb36 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -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 #include @@ -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])) { diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 9871e928520..eac7dc65ace 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -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"); diff --git a/bin/dig/include/dig/dig.h b/bin/dig/include/dig/dig.h index a7ac8a1d635..98b87162d9d 100644 --- a/bin/dig/include/dig/dig.h +++ b/bin/dig/include/dig/dig.h @@ -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;