From cc7732e1299042bff430dfdfbc2624fb340047b2 Mon Sep 17 00:00:00 2001 From: Michael Sawyer Date: Fri, 8 Dec 2000 17:06:52 +0000 Subject: [PATCH] RT#528 fixed --- bin/dig/dig.c | 37 +++++++++++++++++++++++++++++++++++-- bin/dig/dighost.c | 19 ++++++++++++++++--- bin/dig/host.c | 15 ++++++++++++--- bin/dig/include/dig/dig.h | 4 +++- bin/dig/nslookup.c | 5 ++++- 5 files changed, 70 insertions(+), 10 deletions(-) diff --git a/bin/dig/dig.c b/bin/dig/dig.c index 3cf73a3dce..b6aae91c13 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.129 2000/11/21 20:54:59 mws Exp $ */ +/* $Id: dig.c,v 1.130 2000/12/08 17:06:46 mws Exp $ */ #include #include @@ -749,6 +749,7 @@ plus_option(char *option, isc_boolean_t is_batchfile, lookup->section_authority = ISC_FALSE; lookup->section_question = ISC_FALSE; lookup->rdtype = dns_rdatatype_soa; + lookup->rdtypeset = ISC_TRUE; short_form = ISC_TRUE; } break; @@ -942,13 +943,20 @@ dash_option(char *option, char *next, dig_lookup_t **lookup, specified_source = ISC_TRUE; return (value_from_next); case 'c': + if ((*lookup)->rdclassset) { + fprintf(stderr, ";; Warning, ignoring multiple " + "class options\n"); + return (value_from_next); + } *open_type_class = ISC_FALSE; tr.base = value; tr.length = strlen(value); result = dns_rdataclass_fromtext(&rdclass, (isc_textregion_t *)&tr); - if (result == ISC_R_SUCCESS) + if (result == ISC_R_SUCCESS) { (*lookup)->rdclass = rdclass; + (*lookup)->rdclassset = ISC_TRUE; + } else fprintf(stderr, ";; Warning, ignoring " "invalid class %s\n", @@ -965,9 +973,15 @@ dash_option(char *option, char *next, dig_lookup_t **lookup, port = parse_int(value, "port number", MAXPORT); return (value_from_next); case 't': + if ((*lookup)->rdtypeset) { + fprintf(stderr, ";; Warning, ignoring multiple " + "type options\n"); + return (value_from_next); + } *open_type_class = ISC_FALSE; if (strncasecmp(value, "ixfr=", 5) == 0) { (*lookup)->rdtype = dns_rdatatype_ixfr; + (*lookup)->rdtypeset = ISC_TRUE; (*lookup)->ixfr_serial = parse_int(&value[5], "serial number", MAXSERIAL); @@ -981,6 +995,7 @@ dash_option(char *option, char *next, dig_lookup_t **lookup, (isc_textregion_t *)&tr); if (result == ISC_R_SUCCESS) { (*lookup)->rdtype = rdtype; + (*lookup)->rdtypeset = ISC_TRUE; if (rdtype == dns_rdatatype_axfr) { (*lookup)->section_question = plusquest; (*lookup)->comments = pluscomm; @@ -1016,7 +1031,9 @@ dash_option(char *option, char *next, dig_lookup_t **lookup, (*lookup)->ns_search_only); (*lookup)->nibble = nibble; (*lookup)->rdtype = dns_rdatatype_ptr; + (*lookup)->rdtypeset = ISC_TRUE; (*lookup)->rdclass = dns_rdataclass_in; + (*lookup)->rdclassset = ISC_TRUE; (*lookup)->new_search = ISC_TRUE; ISC_LIST_APPEND(lookup_list, *lookup, link); } else { @@ -1170,6 +1187,7 @@ parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only, tr.length = strlen(rv[0]); if (strncmp(rv[0], "ixfr=", 5) == 0) { lookup->rdtype = dns_rdatatype_ixfr; + lookup->rdtypeset = ISC_TRUE; lookup->ixfr_serial = parse_int(&rv[0][5], "serial number", @@ -1182,18 +1200,32 @@ parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only, (isc_textregion_t *)&tr); if ((result == ISC_R_SUCCESS) && (rdtype != dns_rdatatype_ixfr)) { + if (lookup->rdtypeset) { + fprintf(stderr, ";; Warning, " + "ignoring multiple " + "type options\n"); + continue; + } if (rdtype == dns_rdatatype_axfr) { lookup->section_question = plusquest; lookup->comments = pluscomm; } lookup->rdtype = rdtype; + lookup->rdtypeset = ISC_TRUE; continue; } result = dns_rdataclass_fromtext(&rdclass, (isc_textregion_t *)&tr); if (result == ISC_R_SUCCESS) { + if (lookup->rdclassset) { + fprintf(stderr, ";; Warning, " + "ignoring multiple " + "class options\n"); + continue; + } lookup->rdclass = rdclass; + lookup->rdclassset = ISC_TRUE; continue; } } @@ -1264,6 +1296,7 @@ parse_args(isc_boolean_t is_batchfile, isc_boolean_t config_only, lookup->new_search = ISC_TRUE; strcpy(lookup->textname, "."); lookup->rdtype = dns_rdatatype_ns; + lookup->rdtypeset = ISC_TRUE; printgreeting(argc, argv, lookup); ISC_LIST_APPEND(lookup_list, lookup, link); } diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 1de5c79c9e..875906abb4 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.170 2000/12/07 20:15:40 marka Exp $ */ +/* $Id: dighost.c,v 1.171 2000/12/08 17:06:48 mws Exp $ */ /* * Notice to programmers: Do not use this code as an example of how to @@ -343,8 +343,10 @@ make_empty_lookup(void) { looknew->pending = ISC_TRUE; looknew->textname[0] = 0; looknew->cmdline[0] = 0; /* Not copied in clone_lookup! */ - looknew->rdtype = dns_rdatatype_a; - looknew->rdclass = dns_rdataclass_in; + looknew->rdtype = dns_rdatatype_none; + looknew->rdclass = dns_rdataclass_none; + looknew->rdtypeset = ISC_FALSE; + looknew->rdclassset = ISC_FALSE; looknew->sendspace = NULL; looknew->sendmsg = NULL; looknew->name = NULL; @@ -412,6 +414,8 @@ clone_lookup(dig_lookup_t *lookold, isc_boolean_t servers) { looknew->textname[MXNAME-1]=0; looknew->rdtype = lookold->rdtype; looknew->rdclass = lookold->rdclass; + looknew->rdtype = lookold->rdtypeset; + looknew->rdclass = lookold->rdclassset; looknew->doing_xfr = lookold->doing_xfr; looknew->ixfr_serial = lookold->ixfr_serial; looknew->defname = lookold->defname; @@ -1411,6 +1415,15 @@ setup_lookup(dig_lookup_t *lookup) { */ lookup->tcp_mode = ISC_TRUE; } + + /* + * Change NONE lookups to something meaningful. + */ + if (!lookup->rdtypeset) + lookup->rdtype = dns_rdatatype_a; + if (!lookup->rdclassset) + lookup->rdclass = dns_rdataclass_in; + add_question(lookup->sendmsg, lookup->name, lookup->rdclass, lookup->rdtype); diff --git a/bin/dig/host.c b/bin/dig/host.c index ba8dd6aaa3..1023fbcc95 100644 --- a/bin/dig/host.c +++ b/bin/dig/host.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: host.c,v 1.59 2000/10/31 03:21:38 marka Exp $ */ +/* $Id: host.c,v 1.60 2000/12/08 17:06:49 mws Exp $ */ #include #include @@ -560,6 +560,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) { case 'l': lookup->tcp_mode = ISC_TRUE; lookup->rdtype = dns_rdatatype_axfr; + lookup->rdtypeset = ISC_TRUE; break; case 'v': case 'd': @@ -577,8 +578,10 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) { if (result != ISC_R_SUCCESS) fprintf (stderr,"Warning: invalid type: %s\n", isc_commandline_argument); - else + else { lookup->rdtype = rdtype; + lookup->rdtypeset = ISC_TRUE; + } break; case 'c': tr.base = isc_commandline_argument; @@ -589,11 +592,14 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) { if (result != ISC_R_SUCCESS) fprintf (stderr,"Warning: invalid class: %s\n", isc_commandline_argument); - else + else { lookup->rdclass = rdclass; + lookup->rdclassset = ISC_TRUE; + } break; case 'a': lookup->rdtype = dns_rdatatype_any; + lookup->rdtypeset = ISC_TRUE; short_form = ISC_FALSE; break; case 'n': @@ -622,7 +628,9 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) { case 'C': debug("showing all SOAs"); lookup->rdtype = dns_rdatatype_soa; + lookup->rdtypeset = ISC_TRUE; lookup->rdclass = dns_rdataclass_in; + lookup->rdclassset = ISC_TRUE; lookup->ns_search_only = ISC_TRUE; lookup->trace_root = ISC_TRUE; break; @@ -653,6 +661,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) { strncpy(lookup->textname, store, sizeof(lookup->textname)); lookup->textname[sizeof(lookup->textname)-1] = 0; lookup->rdtype = dns_rdatatype_ptr; + lookup->rdtypeset = ISC_TRUE; } else { strncpy(lookup->textname, hostname, sizeof(lookup->textname)); lookup->textname[sizeof(lookup->textname)-1]=0; diff --git a/bin/dig/include/dig/dig.h b/bin/dig/include/dig/dig.h index eacfb8f658..479743bdfd 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.59 2000/11/21 21:40:12 mws Exp $ */ +/* $Id: dig.h,v 1.60 2000/12/08 17:06:52 mws Exp $ */ #ifndef DIG_H #define DIG_H @@ -108,6 +108,8 @@ struct dig_lookup { char cmdline[MXNAME]; dns_rdatatype_t rdtype; dns_rdataclass_t rdclass; + isc_boolean_t rdtypeset; + isc_boolean_t rdclassset; char namespace[BUFSIZE]; char onamespace[BUFSIZE]; isc_buffer_t namebuf; diff --git a/bin/dig/nslookup.c b/bin/dig/nslookup.c index cb49657228..8566182f3f 100644 --- a/bin/dig/nslookup.c +++ b/bin/dig/nslookup.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nslookup.c,v 1.66 2000/12/07 20:15:41 marka Exp $ */ +/* $Id: nslookup.c,v 1.67 2000/12/08 17:06:50 mws Exp $ */ #include @@ -748,11 +748,14 @@ addlookup(char *opt) { if (get_reverse(store, opt, lookup->nibble) == ISC_R_SUCCESS) { safecpy(lookup->textname, store, sizeof(lookup->textname)); lookup->rdtype = dns_rdatatype_ptr; + lookup->rdtypeset = ISC_TRUE; } else { safecpy(lookup->textname, opt, sizeof(lookup->textname)); lookup->rdtype = rdtype; + lookup->rdtypeset = ISC_TRUE; } lookup->rdclass = rdclass; + lookup->rdclassset = ISC_TRUE; lookup->trace = ISC_TF(trace || ns_search_only); lookup->trace_root = trace; lookup->ns_search_only = ns_search_only;