Commit 233514c1 authored by Michael Sawyer's avatar Michael Sawyer
Browse files

Add +besteffort option to dig (on by default) which will cause the

message parser to accept somewhat malformed packets.
parent 10258f6b
......@@ -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])) {
......
......@@ -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");
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment