From: Mark Andrews Date: Fri, 27 Feb 2004 20:41:51 +0000 (+0000) Subject: 1586. [func] "check-names" is now implemented. X-Git-Tag: v9.4.0~88 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=2047977ce2dfcfe3a0fa2d638c3242841310fad3;p=thirdparty%2Fbind9.git 1586. [func] "check-names" is now implemented. --- diff --git a/CHANGES b/CHANGES index ce4d150899e..55d8ef4c868 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ +1586. [func] "check-names" is now implemented. + 1585. [placeholder] rt10497 1584. [placeholder] rt10461 diff --git a/bin/check/named-checkzone.c b/bin/check/named-checkzone.c index 692a9a6846c..3f0711349b3 100644 --- a/bin/check/named-checkzone.c +++ b/bin/check/named-checkzone.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: named-checkzone.c,v 1.27 2004/01/07 05:27:17 marka Exp $ */ +/* $Id: named-checkzone.c,v 1.28 2004/02/27 20:41:41 marka Exp $ */ #include @@ -63,7 +63,7 @@ static void usage(void) { fprintf(stderr, "usage: named-checkzone [-djqvD] [-c class] [-o output] " - "[-t directory] [-w directory] zonename filename\n"); + "[-t directory] [-w directory] [-k option] zonename filename\n"); exit(1); } @@ -84,7 +84,7 @@ main(int argc, char **argv) { char *classname = classname_in; const char *workdir = NULL; - while ((c = isc_commandline_parse(argc, argv, "c:dijn:qst:o:vw:D")) != EOF) { + while ((c = isc_commandline_parse(argc, argv, "c:dijk:n:qst:o:vw:D")) != EOF) { switch (c) { case 'c': classname = isc_commandline_argument; @@ -110,6 +110,16 @@ main(int argc, char **argv) { DNS_ZONEOPT_FATALNS; break; + case 'k': + if (!strcmp(isc_commandline_argument, "check-names")) { + zone_options |= DNS_ZONEOPT_CHECKNAMES; + } else if (!strcmp(isc_commandline_argument, + "check-names-fail")) { + zone_options |= DNS_ZONEOPT_CHECKNAMES | + DNS_ZONEOPT_CHECKNAMESFAIL; + } + break; + case 'q': quiet++; break; diff --git a/bin/check/named-checkzone.docbook b/bin/check/named-checkzone.docbook index a40c99ea2e2..2a567d4dfec 100644 --- a/bin/check/named-checkzone.docbook +++ b/bin/check/named-checkzone.docbook @@ -16,7 +16,7 @@ - WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --> - + @@ -42,6 +42,7 @@ + @@ -112,6 +113,18 @@ + + -k mode + + + Perform "check-name" checks with the specified failure mode. + Possible modes are "fail", + "warn" (default) and + "ignore". + + + + -n mode diff --git a/bin/named/config.c b/bin/named/config.c index 6ef209a4241..3a13915074b 100644 --- a/bin/named/config.c +++ b/bin/named/config.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: config.c,v 1.43 2004/02/17 03:40:19 marka Exp $ */ +/* $Id: config.c,v 1.44 2004/02/27 20:41:41 marka Exp $ */ #include @@ -120,8 +120,8 @@ options {\n\ max-cache-ttl 604800; /* 1 week */\n\ transfer-format many-answers;\n\ max-cache-size 0;\n\ - check-names master ignore;\n\ - check-names slave ignore;\n\ + check-names master fail;\n\ + check-names slave warn;\n\ check-names response ignore;\n\ enable-dnssec no; /* Make yes for 9.4. */ \n\ \n\ diff --git a/bin/named/query.c b/bin/named/query.c index 838af2ec90f..4b2cffbaf76 100644 --- a/bin/named/query.c +++ b/bin/named/query.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: query.c,v 1.254 2004/02/17 03:40:20 marka Exp $ */ +/* $Id: query.c,v 1.255 2004/02/27 20:41:41 marka Exp $ */ #include @@ -2418,6 +2418,26 @@ query_find(ns_client_t *client, dns_fetchevent_t *event, dns_rdatatype_t qtype) version = NULL; need_wildcardproof = ISC_FALSE; + if (client->view->checknames && + !dns_rdata_checkowner(client->query.qname, + client->message->rdclass, + qtype, ISC_FALSE)) { + char namebuf[DNS_NAME_FORMATSIZE]; + char typename[DNS_RDATATYPE_FORMATSIZE]; + char classname[DNS_RDATACLASS_FORMATSIZE]; + + dns_name_format(client->query.qname, namebuf, sizeof(namebuf)); + dns_rdatatype_format(qtype, typename, sizeof(typename)); + dns_rdataclass_format(client->message->rdclass, classname, + sizeof(classname)); + ns_client_log(client, DNS_LOGCATEGORY_SECURITY, + NS_LOGMODULE_QUERY, ISC_LOG_ERROR, + "check-names failure %s/%s/%s", namebuf, + typename, classname); + QUERY_ERROR(DNS_R_REFUSED); + goto cleanup; + } + /* * First we must find the right database. */ diff --git a/bin/named/server.c b/bin/named/server.c index 2798bb16216..682ff3b10d9 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: server.c,v 1.413 2004/02/24 03:31:08 marka Exp $ */ +/* $Id: server.c,v 1.414 2004/02/27 20:41:42 marka Exp $ */ #include @@ -667,9 +667,10 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig, dns_dispatch_t *dispatch6 = NULL; isc_boolean_t reused_cache = ISC_FALSE; int i; - char *str; + const char *str; dns_order_t *order = NULL; isc_uint32_t udpsize; + unsigned int check = 0; REQUIRE(DNS_VIEW_VALID(view)); @@ -792,6 +793,38 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig, dns_cache_detach(&cache); + /* + * Check-names. + */ + obj = NULL; + str = ""; + result = ns_config_get(maps, "check-names", &obj); + INSIST(result == ISC_R_SUCCESS); + for (element = cfg_list_first(obj); + element != NULL; + element = cfg_list_next(element)) { + cfg_obj_t *value, *type; + value = cfg_listelt_value(element); + type = cfg_tuple_get(value, "type"); + if (strcasecmp(cfg_obj_asstring(type), "response") == 0) { + str = cfg_obj_asstring(cfg_tuple_get(value, "mode")); + break; + } + } + + if (strcasecmp(str, "fail") == 0) { + check = DNS_RESOLVER_CHECKNAMES | + DNS_RESOLVER_CHECKNAMESFAIL; + view->checknames = ISC_TRUE; + } else if (strcasecmp(str, "warn") == 0) { + check = DNS_RESOLVER_CHECKNAMES; + view->checknames = ISC_FALSE; + } else if (strcasecmp(str, "ignore") == 0) { + check = 0; + view->checknames = ISC_FALSE; + } else + INSIST(0); + /* * Resolver. * @@ -808,7 +841,7 @@ configure_view(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig, } CHECK(dns_view_createresolver(view, ns_g_taskmgr, 31, ns_g_socketmgr, ns_g_timermgr, - 0, ns_g_dispatchmgr, + check, ns_g_dispatchmgr, dispatch4, dispatch6)); if (dispatch4 != NULL) dns_dispatch_detach(&dispatch4); diff --git a/bin/named/update.c b/bin/named/update.c index 5f4a0bbf9c5..0f4b1d45fa3 100644 --- a/bin/named/update.c +++ b/bin/named/update.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: update.c,v 1.107 2004/02/03 00:59:03 marka Exp $ */ +/* $Id: update.c,v 1.108 2004/02/27 20:41:42 marka Exp $ */ #include @@ -2291,6 +2291,9 @@ update_action(isc_task_t *task, isc_event_t *event) { FAILC(DNS_R_FORMERR, "meta-RR in update"); } + result = dns_zone_checknames(zone, name, &rdata); + if (result != ISC_R_SUCCESS) + FAIL(DNS_R_REFUSED); } else if (update_class == dns_rdataclass_any) { if (ttl != 0 || rdata.length != 0 || (dns_rdatatype_ismeta(rdata.type) && diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index 34722f6ab27..93766636f76 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: zoneconf.c,v 1.108 2004/01/05 06:56:44 marka Exp $ */ +/* $Id: zoneconf.c,v 1.109 2004/02/27 20:41:42 marka Exp $ */ #include @@ -292,6 +292,41 @@ strtoargv(isc_mem_t *mctx, char *s, unsigned int *argcp, char ***argvp) { return (strtoargvsub(mctx, s, argcp, argvp, 0)); } +static void +checknames(dns_zonetype_t ztype, cfg_obj_t **maps, cfg_obj_t **objp) { + const char *zone = NULL; + cfg_listelt_t *element; + cfg_obj_t *type; + cfg_obj_t *value; + cfg_obj_t *check; + int i; + + switch (ztype) { + case dns_zone_slave: zone = "slave"; break; + case dns_zone_master: zone = "master"; break; + default: + INSIST(0); + } + for (i = 0; maps[i] != NULL; i++) { + check = NULL; + cfg_map_get(maps[i], "check-names", &check); + if (check != NULL && !cfg_obj_islist(check)) { + *objp = check; + return; + } + for (element = cfg_list_first(check); + element != NULL; + element = cfg_list_next(element)) { + value = cfg_listelt_value(element); + type = cfg_tuple_get(value, "type"); + if (strcasecmp(cfg_obj_asstring(type), zone) == 0) { + *objp = cfg_tuple_get(value, "mode"); + return; + } + } + } +} + isc_result_t ns_zone_configure(cfg_obj_t *config, cfg_obj_t *vconfig, cfg_obj_t *zconfig, ns_aclconfctx_t *ac, dns_zone_t *zone) @@ -321,6 +356,7 @@ ns_zone_configure(cfg_obj_t *config, cfg_obj_t *vconfig, cfg_obj_t *zconfig, isc_boolean_t multi; isc_boolean_t alt; dns_view_t *view; + isc_boolean_t check = ISC_FALSE, fail = ISC_FALSE; i = 0; if (zconfig != NULL) { @@ -514,6 +550,20 @@ ns_zone_configure(cfg_obj_t *config, cfg_obj_t *vconfig, cfg_obj_t *zconfig, INSIST(result == ISC_R_SUCCESS); dns_zone_setoption(zone, DNS_ZONEOPT_IXFRFROMDIFFS, cfg_obj_asboolean(obj)); + + checknames(ztype, maps, &obj); + INSIST(obj != NULL); + if (strcasecmp(cfg_obj_asstring(obj), "warn") == 0) { + fail = ISC_FALSE; + check = ISC_TRUE; + } else if (strcasecmp(cfg_obj_asstring(obj), "fail") == 0) { + fail = check = ISC_TRUE; + } else if (strcasecmp(cfg_obj_asstring(obj), "ignore") == 0) { + fail = check = ISC_FALSE; + } else + INSIST(0); + dns_zone_setoption(zone, DNS_ZONEOPT_CHECKNAMES, check); + dns_zone_setoption(zone, DNS_ZONEOPT_CHECKNAMESFAIL, fail); } /* diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index 26cb9608cc0..7b5f1d74bb4 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nsupdate.c,v 1.123 2003/07/25 02:22:23 marka Exp $ */ +/* $Id: nsupdate.c,v 1.124 2004/02/27 20:41:42 marka Exp $ */ #include @@ -758,7 +758,7 @@ parse_rdata(char **cmdlinep, dns_rdataclass_t rdataclass, result = isc_buffer_allocate(mctx, &buf, MAXWIRE); check_result(result, "isc_buffer_allocate"); result = dns_rdata_fromtext(rdata, rdataclass, rdatatype, lex, - rn, ISC_FALSE, mctx, buf, + rn, 0, mctx, buf, &callbacks); isc_lex_destroy(&lex); if (result == ISC_R_SUCCESS) { diff --git a/bin/tests/rdata_test.c b/bin/tests/rdata_test.c index 5d9da69b064..87ff6c95228 100644 --- a/bin/tests/rdata_test.c +++ b/bin/tests/rdata_test.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rdata_test.c,v 1.39 2003/09/30 05:56:02 marka Exp $ */ +/* $Id: rdata_test.c,v 1.40 2004/02/27 20:41:42 marka Exp $ */ #include @@ -1013,7 +1013,7 @@ main(int argc, char *argv[]) { dns_rdata_init(&rdata); isc_buffer_init(&dbuf, inbuf, sizeof(inbuf)); result = dns_rdata_fromtext(&rdata, class, type, lex, - NULL, ISC_FALSE, mctx, &dbuf, + NULL, 0, mctx, &dbuf, NULL); if (result != ISC_R_SUCCESS) { fprintf(stdout, @@ -1086,7 +1086,7 @@ main(int argc, char *argv[]) { isc_buffer_init(&dbuf, inbuf, sizeof(inbuf)); dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_ANY); result = dns_rdata_fromwire(&rdata, class, type, &wbuf, - &dctx, ISC_FALSE, &dbuf); + &dctx, 0, &dbuf); dns_decompress_invalidate(&dctx); if (result != ISC_R_SUCCESS) { fprintf(stdout, diff --git a/bin/tests/system/conf.sh.in b/bin/tests/system/conf.sh.in index e933537313d..0d418d63b77 100644 --- a/bin/tests/system/conf.sh.in +++ b/bin/tests/system/conf.sh.in @@ -15,7 +15,7 @@ # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -# $Id: conf.sh.in,v 1.25 2003/09/30 05:56:06 marka Exp $ +# $Id: conf.sh.in,v 1.26 2004/02/27 20:41:43 marka Exp $ # # Common configuration data for system tests, to be sourced into @@ -41,7 +41,7 @@ SIGNER=$TOP/bin/dnssec/dnssec-signzone # The "stress" test is not run by default since it creates enough # load on the machine to make it unusable to other users. # v6synth -SUBDIRS="cacheclean dnssec forward glue ixfr limits lwresd \ +SUBDIRS="cacheclean checknames dnssec forward glue ixfr limits lwresd \ masterfile notify nsupdate resolver sortlist stub tkey \ unknown upforwd views xfer xferquota" diff --git a/lib/dns/gen.c b/lib/dns/gen.c index ddfc952e231..a0dbfd79c81 100644 --- a/lib/dns/gen.c +++ b/lib/dns/gen.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: gen.c,v 1.70 2003/07/25 00:01:05 marka Exp $ */ +/* $Id: gen.c,v 1.71 2004/02/27 20:41:43 marka Exp $ */ #include @@ -34,7 +34,7 @@ #include "gen-unix.h" #endif -#define FROMTEXTARGS "rdclass, type, lexer, origin, downcase, target, callbacks" +#define FROMTEXTARGS "rdclass, type, lexer, origin, options, target, callbacks" #define FROMTEXTCLASS "rdclass" #define FROMTEXTTYPE "type" #define FROMTEXTDEF "result = DNS_R_UNKNOWN" @@ -44,7 +44,7 @@ #define TOTEXTTYPE "rdata->type" #define TOTEXTDEF "use_default = ISC_TRUE" -#define FROMWIREARGS "rdclass, type, source, dctx, downcase, target" +#define FROMWIREARGS "rdclass, type, source, dctx, options, target" #define FROMWIRECLASS "rdclass" #define FROMWIRETYPE "type" #define FROMWIREDEF "use_default = ISC_TRUE" @@ -84,6 +84,16 @@ #define DIGESTTYPE "rdata->type" #define DIGESTDEF "use_default = ISC_TRUE" +#define CHECKOWNERARGS "name, rdclass, type, wildcard" +#define CHECKOWNERCLASS "rdclass" +#define CHECKOWNERTYPE "type" +#define CHECKOWNERDEF "result = ISC_TRUE" + +#define CHECKNAMESARGS "rdata, owner, bad" +#define CHECKNAMESCLASS "rdata->rdclass" +#define CHECKNAMESTYPE "rdata->type" +#define CHECKNAMESDEF "result = ISC_TRUE" + const char copyright[] = "/*\n" " * Copyright (C) 1998%s Internet Software Consortium.\n" @@ -620,6 +630,12 @@ main(int argc, char **argv) { doswitch("DIGESTSWITCH", "digest", DIGESTARGS, DIGESTTYPE, DIGESTCLASS, DIGESTDEF); + doswitch("CHECKOWNERSWITCH", "checkowner", + CHECKOWNERARGS, CHECKOWNERTYPE, + CHECKOWNERCLASS, CHECKOWNERDEF); + doswitch("CHECKNAMESSWITCH", "checknames", + CHECKNAMESARGS, CHECKNAMESTYPE, + CHECKNAMESCLASS, CHECKNAMESDEF); /* * From here down, we are processing the rdata names and diff --git a/lib/dns/include/dns/master.h b/lib/dns/include/dns/master.h index be15c38d451..b5a76d73e4a 100644 --- a/lib/dns/include/dns/master.h +++ b/lib/dns/include/dns/master.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: master.h,v 1.36 2002/07/19 02:34:56 marka Exp $ */ +/* $Id: master.h,v 1.37 2004/02/27 20:41:45 marka Exp $ */ #ifndef DNS_MASTER_H #define DNS_MASTER_H 1 @@ -43,6 +43,8 @@ * they are an address */ #define DNS_MASTER_FATALNS 0x00000080 /* Treat DNS_MASTER_CHECKNS * matches as fatal */ +#define DNS_MASTER_CHECKNAMES 0x00000100 +#define DNS_MASTER_CHECKNAMESFAIL 0x00000200 ISC_LANG_BEGINDECLS diff --git a/lib/dns/include/dns/name.h b/lib/dns/include/dns/name.h index 3e8d52c5a91..12714c4751c 100644 --- a/lib/dns/include/dns/name.h +++ b/lib/dns/include/dns/name.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: name.h,v 1.104 2003/10/25 00:31:12 jinmei Exp $ */ +/* $Id: name.h,v 1.105 2004/02/27 20:41:45 marka Exp $ */ #ifndef DNS_NAME_H #define DNS_NAME_H 1 @@ -140,7 +140,12 @@ struct dns_name { #define DNS_NAMEATTR_NCACHE 0x0400 /* Used by resolver. */ #define DNS_NAMEATTR_CHAINING 0x0800 /* Used by resolver. */ #define DNS_NAMEATTR_CHASE 0x1000 /* Used by resolver. */ -#define DNS_NAMEATTR_WILDCARD 0x2000 /* Used by server */ +#define DNS_NAMEATTR_WILDCARD 0x2000 /* Used by server. */ + +#define DNS_NAME_DOWNCASE 0x0001 +#define DNS_NAME_CHECKNAMES 0x0002 /* Used by rdata. */ +#define DNS_NAME_CHECKNAMESFAIL 0x0004 /* Used by rdata. */ +#define DNS_NAME_CHECKREVERSE 0x0008 /* Used by rdata. */ LIBDNS_EXTERNAL_DATA extern dns_name_t *dns_rootname; LIBDNS_EXTERNAL_DATA extern dns_name_t *dns_wildcardname; @@ -639,7 +644,7 @@ dns_name_toregion(dns_name_t *name, isc_region_t *r); isc_result_t dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, - dns_decompress_t *dctx, isc_boolean_t downcase, + dns_decompress_t *dctx, unsigned int options, isc_buffer_t *target); /* * Copy the possibly-compressed name at source (active region) into target, @@ -648,7 +653,7 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, * Notes: * Decompression policy is controlled by 'dctx'. * - * If 'downcase' is true, any uppercase letters in 'source' will be + * If DNS_NAME_DOWNCASE is set, any uppercase letters in 'source' will be * downcased when they are copied into 'target'. * * Security: @@ -676,8 +681,8 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, * If result is success: * If 'target' is not NULL, 'name' is attached to it. * - * Uppercase letters are downcased in the copy iff. 'downcase' is - * true. + * Uppercase letters are downcased in the copy iff + * DNS_NAME_DOWNCASE is set in options. * * The current location in source is advanced, and the used space * in target is updated. @@ -729,7 +734,7 @@ dns_name_towire(dns_name_t *name, dns_compress_t *cctx, isc_buffer_t *target); isc_result_t dns_name_fromtext(dns_name_t *name, isc_buffer_t *source, - dns_name_t *origin, isc_boolean_t downcase, + dns_name_t *origin, unsigned int options, isc_buffer_t *target); /* * Convert the textual representation of a DNS name at source @@ -740,8 +745,8 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source, * unless 'origin' is NULL, in which case relative domain names * will remain relative. * - * If 'downcase' is true, any uppercase letters in 'source' will be - * downcased when they are copied into 'target'. + * If DNS_NAME_DOWNCASE is set in 'options', any uppercase letters + * in 'source' will be downcased when they are copied into 'target'. * * Requires: * @@ -757,8 +762,8 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source, * If result is success: * If 'target' is not NULL, 'name' is attached to it. * - * Uppercase letters are downcased in the copy iff. 'downcase' is - * true. + * Uppercase letters are downcased in the copy iff + * DNS_NAME_DOWNCASE is set in 'options'. * * The current location in source is advanced, and the used space * in target is updated. @@ -1137,6 +1142,28 @@ dns_name_copy(dns_name_t *source, dns_name_t *dest, isc_buffer_t *target); * ISC_R_NOSPACE */ +isc_boolean_t +dns_name_ishostname(const dns_name_t *name, isc_boolean_t wildcard); +/* + * Return if 'name' is a valid hostname. RFC 952 / RFC 1123. + * If 'wildcard' is ISC_TRUE then allow the first label of name to + * be a wildcard. + * The root is also accepted. + * + * Requires: + * 'name' to be valid. + */ + + +isc_boolean_t +dns_name_ismailbox(const dns_name_t *name); +/* + * Return if 'name' is a valid mailbox. RFC 821. + * + * Requires: + * 'name' to be valid. + */ + ISC_LANG_ENDDECLS /*** diff --git a/lib/dns/include/dns/rdata.h b/lib/dns/include/dns/rdata.h index 5e545eca8f9..c34fa4a01ff 100644 --- a/lib/dns/include/dns/rdata.h +++ b/lib/dns/include/dns/rdata.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rdata.h,v 1.58 2003/10/17 03:46:45 marka Exp $ */ +/* $Id: rdata.h,v 1.59 2004/02/27 20:41:45 marka Exp $ */ #ifndef DNS_RDATA_H #define DNS_RDATA_H 1 @@ -96,6 +96,7 @@ #include #include +#include ISC_LANG_BEGINDECLS @@ -142,6 +143,11 @@ struct dns_rdata { /* Output explanatory comments. */ #define DNS_STYLEFLAG_COMMENT 0x00000002U +#define DNS_RDATA_DOWNCASE DNS_NAME_DOWNCASE +#define DNS_RDATA_CHECKNAMES DNS_NAME_CHECKNAMES +#define DNS_RDATA_CHECKNAMESFAIL DNS_NAME_CHECKNAMESFAIL +#define DNS_RDATA_CHECKREVERSE DNS_NAME_CHECKREVERSE + /*** *** Initialization ***/ @@ -220,8 +226,7 @@ dns_rdata_toregion(const dns_rdata_t *rdata, isc_region_t *r); isc_result_t dns_rdata_fromwire(dns_rdata_t *rdata, dns_rdataclass_t rdclass, dns_rdatatype_t type, isc_buffer_t *source, - dns_decompress_t *dctx, - isc_boolean_t downcase, + dns_decompress_t *dctx, unsigned int options, isc_buffer_t *target); /* * Copy the possibly-compressed rdata at source into the target region. @@ -229,8 +234,9 @@ dns_rdata_fromwire(dns_rdata_t *rdata, dns_rdataclass_t rdclass, * Notes: * Name decompression policy is controlled by 'dctx'. * - * If 'downcase' is true, any uppercase letters in domain names in - * 'source' will be downcased when they are copied into 'target'. + * 'options' + * DNS_RDATA_DOWNCASE downcase domain names when they are copied + * into target. * * Requires: * @@ -294,7 +300,7 @@ dns_rdata_towire(dns_rdata_t *rdata, dns_compress_t *cctx, isc_result_t dns_rdata_fromtext(dns_rdata_t *rdata, dns_rdataclass_t rdclass, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, - isc_boolean_t downcase, isc_mem_t *mctx, + unsigned int options, isc_mem_t *mctx, isc_buffer_t *target, dns_rdatacallbacks_t *callbacks); /* * Convert the textual representation of a DNS rdata into uncompressed wire @@ -305,8 +311,15 @@ dns_rdata_fromtext(dns_rdata_t *rdata, dns_rdataclass_t rdclass, * Relative domain names in the rdata will have 'origin' appended to them. * A NULL origin implies "origin == dns_rootname". * - * If 'downcase' is true, any uppercase letters in domain names in - * 'source' will be downcased when they are copied into 'target'. + * + * 'options' + * DNS_RDATA_DOWNCASE downcase domain names when they are copied + * into target. + * DNS_RDATA_CHECKNAMES perform checknames checks. + * DNS_RDATA_CHECKNAMESFAIL fail if the checknames check fail. If + * not set a warning will be issued. + * DNS_RDATA_CHECKREVERSE this should set if the owner name ends + * in IP6.ARPA, IP6.INT or IN-ADDR.ARPA. * * Requires: * @@ -660,6 +673,34 @@ dns_rdata_covers(dns_rdata_t *rdata); * The type covered. */ +isc_boolean_t +dns_rdata_checkowner(dns_name_t* name, dns_rdataclass_t rdclass, + dns_rdatatype_t type, isc_boolean_t wildcard); +/* + * Returns whether this is a valid ownername for this . + * If wildcard is true allow the first label to be a wildcard if + * appropriate. + * + * Requires: + * 'name' is a valid name. + */ + +isc_boolean_t +dns_rdata_checknames(dns_rdata_t *rdata, dns_name_t *owner, dns_name_t *bad); +/* + * Returns whether 'rdata' contains valid domain names. The checks are + * sensitive to the owner name. + * + * If 'bad' is non-NULL and a domain name fails the check the + * the offending name will be return in 'bad' by cloning from + * the 'rdata' contents. + * + * Requires: + * 'rdata' to be valid. + * 'owner' to be valid. + * 'bad' to be NULL or valid. + */ + ISC_LANG_ENDDECLS #endif /* DNS_RDATA_H */ diff --git a/lib/dns/include/dns/rdataset.h b/lib/dns/include/dns/rdataset.h index f11ae8f299d..17e9fbdd299 100644 --- a/lib/dns/include/dns/rdataset.h +++ b/lib/dns/include/dns/rdataset.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rdataset.h,v 1.49 2004/01/14 02:06:50 marka Exp $ */ +/* $Id: rdataset.h,v 1.50 2004/02/27 20:41:46 marka Exp $ */ #ifndef DNS_RDATASET_H #define DNS_RDATASET_H 1 @@ -145,6 +145,7 @@ struct dns_rdataset { #define DNS_RDATASETATTR_CHASE 0x1000 /* Used by resolver. */ #define DNS_RDATASETATTR_NXDOMAIN 0x2000 #define DNS_RDATASETATTR_NOQNAME 0x4000 +#define DNS_RDATASETATTR_CHECKNAMES 0x8000 /* Used by resolver. */ /* * _OMITDNSSEC: diff --git a/lib/dns/include/dns/resolver.h b/lib/dns/include/dns/resolver.h index b2433ed4133..df2e25a5bb4 100644 --- a/lib/dns/include/dns/resolver.h +++ b/lib/dns/include/dns/resolver.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: resolver.h,v 1.38 2004/01/14 02:06:50 marka Exp $ */ +/* $Id: resolver.h,v 1.39 2004/02/27 20:41:46 marka Exp $ */ #ifndef DNS_RESOLVER_H #define DNS_RESOLVER_H 1 @@ -96,6 +96,9 @@ typedef struct dns_fetchevent { * _dns_resolver_create()). */ +#define DNS_RESOLVER_CHECKNAMES 0x01 +#define DNS_RESOLVER_CHECKNAMESFAIL 0x02 + isc_result_t dns_resolver_create(dns_view_t *view, isc_taskmgr_t *taskmgr, unsigned int ntasks, @@ -106,6 +109,7 @@ dns_resolver_create(dns_view_t *view, dns_dispatch_t *dispatchv4, dns_dispatch_t *dispatchv6, dns_resolver_t **resp); + /* * Create a resolver. * diff --git a/lib/dns/include/dns/result.h b/lib/dns/include/dns/result.h index d14f92b5343..3f5799b0e7d 100644 --- a/lib/dns/include/dns/result.h +++ b/lib/dns/include/dns/result.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: result.h,v 1.100 2004/01/14 02:06:50 marka Exp $ */ +/* $Id: result.h,v 1.101 2004/02/27 20:41:46 marka Exp $ */ #ifndef DNS_RESULT_H #define DNS_RESULT_H 1 @@ -137,8 +137,10 @@ #define DNS_R_EMPTYWILD (ISC_RESULTCLASS_DNS + 93) #define DNS_R_BADBITMAP (ISC_RESULTCLASS_DNS + 94) #define DNS_R_FROMWILDCARD (ISC_RESULTCLASS_DNS + 95) +#define DNS_R_BADOWNERNAME (ISC_RESULTCLASS_DNS + 96) +#define DNS_R_BADNAME (ISC_RESULTCLASS_DNS + 97) -#define DNS_R_NRESULTS 96 /* Number of results */ +#define DNS_R_NRESULTS 98 /* Number of results */ /* * DNS wire format rcodes. diff --git a/lib/dns/include/dns/view.h b/lib/dns/include/dns/view.h index e1dae7f1eb4..23fb45f0a49 100644 --- a/lib/dns/include/dns/view.h +++ b/lib/dns/include/dns/view.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: view.h,v 1.88 2004/02/17 03:40:23 marka Exp $ */ +/* $Id: view.h,v 1.89 2004/02/27 20:41:46 marka Exp $ */ #ifndef DNS_VIEW_H #define DNS_VIEW_H 1 @@ -123,6 +123,7 @@ struct dns_view { dns_namelist_t * delonly; isc_boolean_t rootdelonly; dns_namelist_t * rootexclude; + isc_boolean_t checknames; /* * Configurable data for server use only, diff --git a/lib/dns/include/dns/zone.h b/lib/dns/include/dns/zone.h index 80d7fd952be..81bd2ff82b1 100644 --- a/lib/dns/include/dns/zone.h +++ b/lib/dns/include/dns/zone.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: zone.h,v 1.124 2004/01/07 05:27:17 marka Exp $ */ +/* $Id: zone.h,v 1.125 2004/02/27 20:41:46 marka Exp $ */ #ifndef DNS_ZONE_H #define DNS_ZONE_H 1 @@ -50,6 +50,8 @@ typedef enum { #define DNS_ZONEOPT_FATALNS 0x00000100U /* DNS_ZONEOPT_CHECKNS is fatal */ #define DNS_ZONEOPT_MULTIMASTER 0x00000200U /* this zone has multiple masters */ #define DNS_ZONEOPT_USEALTXFRSRC 0x00000400U /* use alternate transfer sources */ +#define DNS_ZONEOPT_CHECKNAMES 0x00000800U /* check-names */ +#define DNS_ZONEOPT_CHECKNAMESFAIL 0x00001000U /* fatal check-name failures */ #ifndef NOMINUM_PUBLIC /* @@ -1407,6 +1409,22 @@ dns_zone_name(dns_zone_t *zone, char *buf, size_t len); * 'buf' to be non NULL. */ +isc_result_t +dns_zone_checknames(dns_zone_t *zone, dns_name_t *name, dns_rdata_t *rdata); +/* + * Check if this record meets the check-names policy. + * + * Requires: + * 'zone' to be valid. + * 'name' to be valid. + * 'rdata' to be valid. + * + * Returns: + * DNS_R_SUCCESS passed checks. + * DNS_R_BADOWNERNAME failed ownername checks. + * DNS_R_BADNAME failed rdata checks. + */ + ISC_LANG_ENDDECLS #endif /* DNS_ZONE_H */ diff --git a/lib/dns/journal.c b/lib/dns/journal.c index 9bfece488b0..833851220d3 100644 --- a/lib/dns/journal.c +++ b/lib/dns/journal.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: journal.c,v 1.84 2002/07/22 02:06:04 marka Exp $ */ +/* $Id: journal.c,v 1.85 2004/02/27 20:41:43 marka Exp $ */ #include @@ -1597,7 +1597,7 @@ read_one_rr(dns_journal_t *j) { isc_buffer_setactive(&j->it.source, j->it.source.used - j->it.source.current); CHECK(dns_name_fromwire(&j->it.name, &j->it.source, - &j->it.dctx, ISC_FALSE, &j->it.target)); + &j->it.dctx, 0, &j->it.target)); /* * Check that the RR header is there, and parse it. @@ -1617,7 +1617,7 @@ read_one_rr(dns_journal_t *j) { dns_rdata_reset(&j->it.rdata); CHECK(dns_rdata_fromwire(&j->it.rdata, rdclass, rdtype, &j->it.source, &j->it.dctx, - ISC_FALSE, &j->it.target)); + 0, &j->it.target)); j->it.ttl = ttl; j->it.xpos += sizeof(journal_rawrrhdr_t) + rrhdr.size; diff --git a/lib/dns/master.c b/lib/dns/master.c index 8a9d69155dd..e0a9e797c6b 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: master.c,v 1.146 2003/09/30 05:56:11 marka Exp $ */ +/* $Id: master.c,v 1.147 2004/02/27 20:41:43 marka Exp $ */ #include @@ -272,6 +272,44 @@ loadctx_destroy(dns_loadctx_t *lctx); "dns_master_load", \ source, line, dns_result_totext(result)) + +static unsigned char in_addr_arpa_data[] = "\007IN-ADDR\004ARPA"; +static unsigned char in_addr_arpa_offsets[] = { 0, 8, 13 }; +static const dns_name_t in_addr_arpa = +{ + DNS_NAME_MAGIC, + in_addr_arpa_data, 14, 3, + DNS_NAMEATTR_READONLY | DNS_NAMEATTR_ABSOLUTE, + in_addr_arpa_offsets, NULL, + {(void *)-1, (void *)-1}, + {NULL, NULL} +}; + +static unsigned char ip6_int_data[] = "\003IP6\003INT"; +static unsigned char ip6_int_offsets[] = { 0, 4, 8 }; +static const dns_name_t ip6_int = +{ + DNS_NAME_MAGIC, + ip6_int_data, 9, 3, + DNS_NAMEATTR_READONLY | DNS_NAMEATTR_ABSOLUTE, + ip6_int_offsets, NULL, + {(void *)-1, (void *)-1}, + {NULL, NULL} +}; + +static unsigned char ip6_arpa_data[] = "\003IP6\004ARPA"; +static unsigned char ip6_arpa_offsets[] = { 0, 4, 9 }; +static const dns_name_t ip6_arpa = +{ + DNS_NAME_MAGIC, + ip6_arpa_data, 10, 3, + DNS_NAMEATTR_READONLY | DNS_NAMEATTR_ABSOLUTE, + ip6_arpa_offsets, NULL, + {(void *)-1, (void *)-1}, + {NULL, NULL} +}; + + static inline isc_result_t gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *token, isc_boolean_t eol, dns_rdatacallbacks_t *callbacks) @@ -698,7 +736,7 @@ generate(dns_loadctx_t *lctx, char *range, char *lhs, char *gtype, char *rhs, isc_buffer_add(&buffer, strlen(lhsbuf)); isc_buffer_setactive(&buffer, strlen(lhsbuf)); result = dns_name_fromtext(owner, &buffer, ictx->origin, - ISC_FALSE, NULL); + 0, NULL); if (result != ISC_R_SUCCESS) goto error_cleanup; @@ -728,7 +766,7 @@ generate(dns_loadctx_t *lctx, char *range, char *lhs, char *gtype, char *rhs, isc_buffer_init(&target, target_mem, target_size); result = dns_rdata_fromtext(&rdata, lctx->zclass, type, - lctx->lex, ictx->origin, ISC_FALSE, + lctx->lex, ictx->origin, 0, lctx->mctx, &target, callbacks); RUNTIME_CHECK(isc_lex_close(lctx->lex) == ISC_R_SUCCESS); if (result != ISC_R_SUCCESS) @@ -873,6 +911,7 @@ load(dns_loadctx_t *lctx) { isc_stdtime_t now; char classname1[DNS_RDATACLASS_FORMATSIZE]; char classname2[DNS_RDATACLASS_FORMATSIZE]; + unsigned int options = 0; REQUIRE(DNS_LCTX_VALID(lctx)); callbacks = lctx->callbacks; @@ -896,6 +935,10 @@ load(dns_loadctx_t *lctx) { isc_buffer_init(&target, target_mem, target_size); target_save = target; + if ((lctx->options & DNS_MASTER_CHECKNAMES) != 0) + options |= DNS_RDATA_CHECKNAMES; + if ((lctx->options & DNS_MASTER_CHECKNAMESFAIL) != 0) + options |= DNS_RDATA_CHECKNAMESFAIL; source = isc_lex_getsourcename(lctx->lex); do { initialws = ISC_FALSE; @@ -1520,6 +1563,47 @@ load(dns_loadctx_t *lctx) { } } + /* + * Check owner name. + */ + options &= ~DNS_RDATA_CHECKREVERSE; + if ((lctx->options & DNS_MASTER_CHECKNAMES) != 0) { + isc_boolean_t ok; + dns_name_t *name; + + name = (ictx->glue != NULL) ? ictx-> glue : + ictx->current; + ok = dns_rdata_checkowner(name, lctx->zclass, type, + ISC_TRUE); + if (!ok) { + char namebuf[DNS_NAME_FORMATSIZE]; + const char *desc; + dns_name_format(name, namebuf, sizeof(namebuf)); + result = DNS_R_BADOWNERNAME; + desc = dns_result_totext(result); + if ((lctx->options & DNS_MASTER_CHECKNAMESFAIL) != 0) { + (*callbacks->error)(callbacks, + "%s:%lu: %s: %s", + source, line, + namebuf, desc); + if (MANYERRS(lctx, result)) { + SETRESULT(lctx, result); + } else if (result != ISC_R_SUCCESS) + goto cleanup; + } else { + (*callbacks->warn)(callbacks, + "%s:%lu: %s: %s", + source, line, + namebuf, desc); + } + } + if (type == dns_rdatatype_ptr && + (dns_name_issubdomain(name, &in_addr_arpa) || + dns_name_issubdomain(name, &ip6_arpa) || + dns_name_issubdomain(name, &ip6_int))) + options |= DNS_RDATA_CHECKREVERSE; + } + /* * Read rdata contents. */ @@ -1527,7 +1611,7 @@ load(dns_loadctx_t *lctx) { target_ft = target; result = dns_rdata_fromtext(&rdata[rdcount], lctx->zclass, type, lctx->lex, ictx->origin, - ISC_FALSE, lctx->mctx, &target, + options, lctx->mctx, &target, callbacks); if (MANYERRS(lctx, result)) { SETRESULT(lctx, result); diff --git a/lib/dns/message.c b/lib/dns/message.c index dedbf4f7dc2..d89a0435f3f 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: message.c,v 1.219 2003/09/30 05:56:12 marka Exp $ */ +/* $Id: message.c,v 1.220 2004/02/27 20:41:43 marka Exp $ */ /*** *** Imports @@ -889,7 +889,7 @@ getrdata(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx, /* XXX possibly change this to a while (tries < 2) loop */ for (;;) { result = dns_rdata_fromwire(rdata, rdclass, rdtype, - source, dctx, ISC_FALSE, + source, dctx, 0, scratch); if (result == ISC_R_NOSPACE) { diff --git a/lib/dns/name.c b/lib/dns/name.c index be890f18914..12969f97244 100644 --- a/lib/dns/name.c +++ b/lib/dns/name.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: name.c,v 1.142 2003/10/25 00:31:10 jinmei Exp $ */ +/* $Id: name.c,v 1.143 2004/02/27 20:41:44 marka Exp $ */ #include @@ -258,6 +258,110 @@ dns_name_isabsolute(const dns_name_t *name) { return (ISC_FALSE); } +#define hyphenchar(c) ((c) == 0x2d) +#define asterchar(c) ((c) == 0x2a) +#define alphachar(c) (((c) >= 0x41 && (c) <= 0x5a) \ + || ((c) >= 0x61 && (c) <= 0x7a)) +#define digitchar(c) ((c) >= 0x30 && (c) <= 0x39) +#define borderchar(c) (alphachar(c) || digitchar(c)) +#define middlechar(c) (borderchar(c) || hyphenchar(c)) +#define domainchar(c) ((c) > 0x20 && (c) < 0x7f) + +isc_boolean_t +dns_name_ismailbox(const dns_name_t *name) { + unsigned char *ndata, ch; + unsigned int n; + isc_boolean_t first; + + REQUIRE(VALID_NAME(name)); + REQUIRE(name->labels > 0); + REQUIRE(name->attributes & DNS_NAMEATTR_ABSOLUTE); + + /* + * Root label. + */ + if (name->length == 1) + return (ISC_TRUE); + + ndata = name->ndata; + n = *ndata++; + INSIST(n < 63); + while (n--) { + ch = *ndata++; + if (!domainchar(ch)) + return (ISC_FALSE); + } + + if (ndata == name->ndata + name->length) + return (ISC_FALSE); + + /* + * RFC292/RFC1123 hostname. + */ + while (ndata < (name->ndata + name->length)) { + n = *ndata++; + INSIST(n < 63); + first = ISC_TRUE; + while (n--) { + ch = *ndata++; + if (first || n == 0) { + if (!borderchar(ch)) + return (ISC_FALSE); + } else { + if (!middlechar(ch)) + return (ISC_FALSE); + } + first = ISC_FALSE; + } + } + return (ISC_TRUE); +} + +isc_boolean_t +dns_name_ishostname(const dns_name_t *name, isc_boolean_t wildcard) { + unsigned char *ndata, ch; + unsigned int n; + isc_boolean_t first; + + REQUIRE(VALID_NAME(name)); + REQUIRE(name->labels > 0); + REQUIRE(name->attributes & DNS_NAMEATTR_ABSOLUTE); + + /* + * Root label. + */ + if (name->length == 1) + return (ISC_TRUE); + + /* + * Skip wildcard if this is a ownername. + */ + ndata = name->ndata; + if (wildcard && ndata[0] == 1 && ndata[1] == '*') + ndata += 2; + + /* + * RFC292/RFC1123 hostname. + */ + while (ndata < (name->ndata + name->length)) { + n = *ndata++; + INSIST(n < 63); + first = ISC_TRUE; + while (n--) { + ch = *ndata++; + if (first || n == 0) { + if (!borderchar(ch)) + return (ISC_FALSE); + } else { + if (!middlechar(ch)) + return (ISC_FALSE); + } + first = ISC_FALSE; + } + } + return (ISC_TRUE); +} + isc_boolean_t dns_name_iswildcard(const dns_name_t *name) { unsigned char *ndata; @@ -820,7 +924,7 @@ dns_name_toregion(dns_name_t *name, isc_region_t *r) { isc_result_t dns_name_fromtext(dns_name_t *name, isc_buffer_t *source, - dns_name_t *origin, isc_boolean_t downcase, + dns_name_t *origin, unsigned int options, isc_buffer_t *target) { unsigned char *ndata, *label; @@ -832,6 +936,7 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source, isc_boolean_t done; unsigned char *offsets; dns_offsets_t odata; + isc_boolean_t downcase; /* * Convert the textual representation of a DNS name at source @@ -847,6 +952,8 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source, REQUIRE(ISC_BUFFER_VALID(source)); REQUIRE((target != NULL && ISC_BUFFER_VALID(target)) || (target == NULL && ISC_BUFFER_VALID(name->buffer))); + + downcase = ISC_TF((options & DNS_NAME_DOWNCASE) != 0); if (target == NULL && name->buffer != NULL) { target = name->buffer; @@ -1452,7 +1559,7 @@ set_offsets(const dns_name_t *name, unsigned char *offsets, isc_result_t dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, - dns_decompress_t *dctx, isc_boolean_t downcase, + dns_decompress_t *dctx, unsigned int options, isc_buffer_t *target) { unsigned char *cdata, *ndata; @@ -1464,6 +1571,7 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, unsigned int c; unsigned char *offsets; dns_offsets_t odata; + isc_boolean_t downcase; /* * Copy the possibly-compressed name at source into target, @@ -1474,6 +1582,8 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source, REQUIRE((target != NULL && ISC_BUFFER_VALID(target)) || (target == NULL && ISC_BUFFER_VALID(name->buffer))); + downcase = ISC_TF((options & DNS_NAME_DOWNCASE) != 0); + if (target == NULL && name->buffer != NULL) { target = name->buffer; isc_buffer_clear(target); diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index eb9782b1e10..33388fb7121 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rdata.c,v 1.181 2003/10/17 03:46:43 marka Exp $ */ +/* $Id: rdata.c,v 1.182 2004/02/27 20:41:44 marka Exp $ */ #include #include @@ -66,7 +66,7 @@ #define ARGS_FROMTEXT int rdclass, dns_rdatatype_t type, \ isc_lex_t *lexer, dns_name_t *origin, \ - isc_boolean_t downcase, isc_buffer_t *target, \ + unsigned int options, isc_buffer_t *target, \ dns_rdatacallbacks_t *callbacks #define ARGS_TOTEXT dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, \ @@ -74,7 +74,7 @@ #define ARGS_FROMWIRE int rdclass, dns_rdatatype_t type, \ isc_buffer_t *source, dns_decompress_t *dctx, \ - isc_boolean_t downcase, isc_buffer_t *target + unsigned int options, isc_buffer_t *target #define ARGS_TOWIRE dns_rdata_t *rdata, dns_compress_t *cctx, \ isc_buffer_t *target @@ -93,6 +93,12 @@ #define ARGS_DIGEST dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg +#define ARGS_CHECKOWNER dns_name_t *name, dns_rdataclass_t rdclass, \ + dns_rdatatype_t type, isc_boolean_t wildcard + +#define ARGS_CHECKNAMES dns_rdata_t *rdata, dns_name_t *owner, dns_name_t *bad + + /* * Context structure for the totext_ functions. * Contains formatting options for rdata-to-text @@ -184,6 +190,10 @@ static isc_result_t rdata_totext(dns_rdata_t *rdata, dns_rdata_textctx_t *tctx, isc_buffer_t *target); +static void +warn_badname(dns_name_t *name, isc_lex_t *lexer, + dns_rdatacallbacks_t *callbacks); + static inline int getquad(const void *src, struct in_addr *dst, isc_lex_t *lexer, dns_rdatacallbacks_t *callbacks) @@ -493,7 +503,7 @@ dns_rdata_toregion(const dns_rdata_t *rdata, isc_region_t *r) { isc_result_t dns_rdata_fromwire(dns_rdata_t *rdata, dns_rdataclass_t rdclass, dns_rdatatype_t type, isc_buffer_t *source, - dns_decompress_t *dctx, isc_boolean_t downcase, + dns_decompress_t *dctx, unsigned int options, isc_buffer_t *target) { isc_result_t result = ISC_R_NOTIMPLEMENTED; @@ -607,7 +617,7 @@ rdata_validate(isc_buffer_t *src, isc_buffer_t *dest, dns_rdataclass_t rdclass, dns_decompress_init(&dctx, -1, DNS_DECOMPRESS_NONE); isc_buffer_setactive(src, isc_buffer_usedlength(src)); result = dns_rdata_fromwire(&rdata, rdclass, type, src, - &dctx, ISC_FALSE, dest); + &dctx, 0, dest); dns_decompress_invalidate(&dctx); return (result); @@ -662,15 +672,15 @@ unknown_fromtext(dns_rdataclass_t rdclass, dns_rdatatype_t type, isc_result_t dns_rdata_fromtext(dns_rdata_t *rdata, dns_rdataclass_t rdclass, dns_rdatatype_t type, isc_lex_t *lexer, - dns_name_t *origin, isc_boolean_t downcase, isc_mem_t *mctx, + dns_name_t *origin, unsigned int options, isc_mem_t *mctx, isc_buffer_t *target, dns_rdatacallbacks_t *callbacks) { isc_result_t result = ISC_R_NOTIMPLEMENTED; isc_region_t region; isc_buffer_t st; isc_token_t token; - unsigned int options = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF | - ISC_LEXOPT_DNSMULTILINE | ISC_LEXOPT_ESCAPE; + unsigned int lexoptions = ISC_LEXOPT_EOL | ISC_LEXOPT_EOF | + ISC_LEXOPT_DNSMULTILINE | ISC_LEXOPT_ESCAPE; char *name; unsigned long line; void (*callback)(dns_rdatacallbacks_t *, const char *, ...); @@ -719,7 +729,7 @@ dns_rdata_fromtext(dns_rdata_t *rdata, dns_rdataclass_t rdclass, do { name = isc_lex_getsourcename(lexer); line = isc_lex_getsourceline(lexer); - tresult = isc_lex_gettoken(lexer, options, &token); + tresult = isc_lex_gettoken(lexer, lexoptions, &token); if (tresult != ISC_R_SUCCESS) { if (result == ISC_R_SUCCESS) result = tresult; @@ -955,6 +965,25 @@ dns_rdata_digest(dns_rdata_t *rdata, dns_digestfunc_t digest, void *arg) { return (result); } +isc_boolean_t +dns_rdata_checkowner(dns_name_t *name, dns_rdataclass_t rdclass, + dns_rdatatype_t type, isc_boolean_t wildcard) +{ + isc_boolean_t result; + + CHECKOWNERSWITCH + return (result); +} + +isc_boolean_t +dns_rdata_checknames(dns_rdata_t *rdata, dns_name_t *owner, dns_name_t *bad) +{ + isc_boolean_t result; + + CHECKNAMESSWITCH + return (result); +} + unsigned int dns_rdatatype_attributes(dns_rdatatype_t type) { @@ -1965,6 +1994,24 @@ fromtext_warneof(isc_lex_t *lexer, dns_rdatacallbacks_t *callbacks) { } } +static void +warn_badname(dns_name_t *name, isc_lex_t *lexer, + dns_rdatacallbacks_t *callbacks) +{ + const char *file; + unsigned long line; + char namebuf[DNS_NAME_FORMATSIZE]; + + if (lexer != NULL) { + file = isc_lex_getsourcename(lexer); + line = isc_lex_getsourceline(lexer); + dns_name_format(name, namebuf, sizeof(namebuf)); + (*callbacks->warn)(callbacks, "%s:%u: %s: %s", + file, line, namebuf, + dns_result_totext(DNS_R_BADNAME)); + } +} + static void fromtext_error(void (*callback)(dns_rdatacallbacks_t *, const char *, ...), dns_rdatacallbacks_t *callbacks, const char *name, @@ -2089,4 +2136,3 @@ dns_rdatatype_isknown(dns_rdatatype_t type) { return (ISC_TRUE); return (ISC_FALSE); } - diff --git a/lib/dns/rdata/any_255/tsig_250.c b/lib/dns/rdata/any_255/tsig_250.c index 8545690aca5..17b4f1fa3b7 100644 --- a/lib/dns/rdata/any_255/tsig_250.c +++ b/lib/dns/rdata/any_255/tsig_250.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: tsig_250.c,v 1.57 2003/07/25 00:01:07 marka Exp $ */ +/* $Id: tsig_250.c,v 1.58 2004/02/27 20:41:46 marka Exp $ */ /* Reviewed: Thu Mar 16 13:39:43 PST 2000 by gson */ @@ -50,7 +50,7 @@ fromtext_any_tsig(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); /* * Time Signed: 48 bits. @@ -260,7 +260,7 @@ fromwire_any_tsig(ARGS_FROMWIRE) { * Algorithm Name. */ dns_name_init(&name, NULL); - RETERR(dns_name_fromwire(&name, source, dctx, downcase, target)); + RETERR(dns_name_fromwire(&name, source, dctx, options, target)); isc_buffer_activeregion(source, &sr); /* @@ -563,4 +563,31 @@ digest_any_tsig(ARGS_DIGEST) { return (ISC_R_NOTIMPLEMENTED); } +static inline isc_boolean_t +checkowner_any_tsig(ARGS_CHECKOWNER) { + + REQUIRE(type == 250); + REQUIRE(rdclass == 255); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_any_tsig(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 250); + REQUIRE(rdata->rdclass == 250); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_ANY_255_TSIG_250_C */ diff --git a/lib/dns/rdata/generic/afsdb_18.c b/lib/dns/rdata/generic/afsdb_18.c index 8b0194d19b6..9063959b7df 100644 --- a/lib/dns/rdata/generic/afsdb_18.c +++ b/lib/dns/rdata/generic/afsdb_18.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: afsdb_18.c,v 1.41 2003/07/25 00:01:08 marka Exp $ */ +/* $Id: afsdb_18.c,v 1.42 2004/02/27 20:41:46 marka Exp $ */ /* Reviewed: Wed Mar 15 14:59:00 PST 2000 by explorer */ @@ -31,6 +31,7 @@ fromtext_afsdb(ARGS_FROMTEXT) { isc_token_t token; isc_buffer_t buffer; dns_name_t name; + isc_boolean_t ok; REQUIRE(type == 18); @@ -55,7 +56,14 @@ fromtext_afsdb(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); + ok = ISC_TRUE; + if ((options & DNS_RDATA_CHECKNAMES) != 0) + ok = dns_name_ishostname(&name, ISC_FALSE); + if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) + RETTOK(DNS_R_BADNAME); + if (!ok && callbacks != NULL) + warn_badname(&name, lexer, callbacks); return (ISC_R_SUCCESS); } @@ -108,7 +116,7 @@ fromwire_afsdb(ARGS_FROMWIRE) { memcpy(tr.base, sr.base, 2); isc_buffer_forward(source, 2); isc_buffer_add(target, 2); - return (dns_name_fromwire(&name, source, dctx, downcase, target)); + return (dns_name_fromwire(&name, source, dctx, options, target)); } static inline isc_result_t @@ -264,4 +272,38 @@ digest_afsdb(ARGS_DIGEST) { return (dns_name_digest(&name, digest, arg)); } +static inline isc_boolean_t +checkowner_afsdb(ARGS_CHECKOWNER) { + + REQUIRE(type == 18); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_afsdb(ARGS_CHECKNAMES) { + isc_region_t region; + dns_name_t name; + + REQUIRE(rdata->type == 18); + + UNUSED(owner); + + dns_rdata_toregion(rdata, ®ion); + isc_region_consume(®ion, 2); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, ®ion); + if (!dns_name_ishostname(&name, ISC_FALSE)) { + if (bad != NULL) + dns_name_clone(&name, bad); + return (ISC_FALSE); + } + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_AFSDB_18_C */ diff --git a/lib/dns/rdata/generic/cert_37.c b/lib/dns/rdata/generic/cert_37.c index 575e4c3dae9..6a30f48ec39 100644 --- a/lib/dns/rdata/generic/cert_37.c +++ b/lib/dns/rdata/generic/cert_37.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: cert_37.c,v 1.44 2003/07/25 00:01:08 marka Exp $ */ +/* $Id: cert_37.c,v 1.45 2004/02/27 20:41:47 marka Exp $ */ /* Reviewed: Wed Mar 15 21:14:32 EST 2000 by tale */ @@ -37,7 +37,7 @@ fromtext_cert(ARGS_FROMTEXT) { UNUSED(type); UNUSED(rdclass); UNUSED(origin); - UNUSED(downcase); + UNUSED(options); UNUSED(callbacks); /* @@ -125,7 +125,7 @@ fromwire_cert(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); UNUSED(dctx); - UNUSED(downcase); + UNUSED(options); isc_buffer_activeregion(source, &sr); if (sr.length < 5) @@ -251,4 +251,30 @@ digest_cert(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_cert(ARGS_CHECKOWNER) { + + REQUIRE(type == 37); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_cert(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 37); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_CERT_37_C */ + diff --git a/lib/dns/rdata/generic/cname_5.c b/lib/dns/rdata/generic/cname_5.c index d597b90ea71..0cd4fb1cd34 100644 --- a/lib/dns/rdata/generic/cname_5.c +++ b/lib/dns/rdata/generic/cname_5.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: cname_5.c,v 1.43 2001/07/16 03:06:03 marka Exp $ */ +/* $Id: cname_5.c,v 1.44 2004/02/27 20:41:47 marka Exp $ */ /* reviewed: Wed Mar 15 16:48:45 PST 2000 by brister */ @@ -43,7 +43,7 @@ fromtext_cname(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); return (ISC_R_SUCCESS); } @@ -80,7 +80,7 @@ fromwire_cname(ARGS_FROMWIRE) { dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); dns_name_init(&name, NULL); - return (dns_name_fromwire(&name, source, dctx, downcase, target)); + return (dns_name_fromwire(&name, source, dctx, options, target)); } static inline isc_result_t @@ -204,4 +204,29 @@ digest_cname(ARGS_DIGEST) { return (dns_name_digest(&name, digest, arg)); } +static inline isc_boolean_t +checkowner_cname(ARGS_CHECKOWNER) { + + REQUIRE(type == 5); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_cname(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 5); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_CNAME_5_C */ diff --git a/lib/dns/rdata/generic/dname_39.c b/lib/dns/rdata/generic/dname_39.c index 2f0d5f2f752..c16b4a2f28c 100644 --- a/lib/dns/rdata/generic/dname_39.c +++ b/lib/dns/rdata/generic/dname_39.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dname_39.c,v 1.34 2001/07/16 03:06:04 marka Exp $ */ +/* $Id: dname_39.c,v 1.35 2004/02/27 20:41:47 marka Exp $ */ /* Reviewed: Wed Mar 15 16:52:38 PST 2000 by explorer */ @@ -44,7 +44,7 @@ fromtext_dname(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); return (ISC_R_SUCCESS); } @@ -81,7 +81,7 @@ fromwire_dname(ARGS_FROMWIRE) { dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE); dns_name_init(&name, NULL); - return(dns_name_fromwire(&name, source, dctx, downcase, target)); + return(dns_name_fromwire(&name, source, dctx, options, target)); } static inline isc_result_t @@ -205,4 +205,29 @@ digest_dname(ARGS_DIGEST) { return (dns_name_digest(&name, digest, arg)); } +static inline isc_boolean_t +checkowner_dname(ARGS_CHECKOWNER) { + + REQUIRE(type == 39); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_dname(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 39); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_DNAME_39_C */ diff --git a/lib/dns/rdata/generic/dnskey_48.c b/lib/dns/rdata/generic/dnskey_48.c index be9963fe9a8..733962e4886 100644 --- a/lib/dns/rdata/generic/dnskey_48.c +++ b/lib/dns/rdata/generic/dnskey_48.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dnskey_48.c,v 1.2 2003/09/30 06:00:40 marka Exp $ */ +/* $Id: dnskey_48.c,v 1.3 2004/02/27 20:41:47 marka Exp $ */ /* * Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley. @@ -42,7 +42,7 @@ fromtext_dnskey(ARGS_FROMTEXT) { UNUSED(type); UNUSED(rdclass); UNUSED(origin); - UNUSED(downcase); + UNUSED(options); UNUSED(callbacks); /* flags */ @@ -140,7 +140,7 @@ fromwire_dnskey(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); UNUSED(dctx); - UNUSED(downcase); + UNUSED(options); isc_buffer_activeregion(source, &sr); if (sr.length < 4) @@ -284,4 +284,29 @@ digest_dnskey(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_dnskey(ARGS_CHECKOWNER) { + + REQUIRE(type == 48); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_dnskey(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 48); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_DNSKEY_48_C */ diff --git a/lib/dns/rdata/generic/ds_43.c b/lib/dns/rdata/generic/ds_43.c index fc2cf3db7ec..3147788f20b 100644 --- a/lib/dns/rdata/generic/ds_43.c +++ b/lib/dns/rdata/generic/ds_43.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ds_43.c,v 1.4 2002/12/20 01:19:20 marka Exp $ */ +/* $Id: ds_43.c,v 1.5 2004/02/27 20:41:47 marka Exp $ */ /* draft-ietf-dnsext-delegation-signer-05.txt */ @@ -34,7 +34,7 @@ fromtext_ds(ARGS_FROMTEXT) { UNUSED(type); UNUSED(rdclass); UNUSED(origin); - UNUSED(downcase); + UNUSED(options); UNUSED(callbacks); /* @@ -129,7 +129,7 @@ fromwire_ds(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); UNUSED(dctx); - UNUSED(downcase); + UNUSED(options); isc_buffer_activeregion(source, &sr); if (sr.length < 4) @@ -255,4 +255,29 @@ digest_ds(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_ds(ARGS_CHECKOWNER) { + + REQUIRE(type == 43); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_ds(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 43); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_DS_43_C */ diff --git a/lib/dns/rdata/generic/gpos_27.c b/lib/dns/rdata/generic/gpos_27.c index 1591a1146d4..08376a0f7c7 100644 --- a/lib/dns/rdata/generic/gpos_27.c +++ b/lib/dns/rdata/generic/gpos_27.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: gpos_27.c,v 1.35 2002/02/20 03:34:47 marka Exp $ */ +/* $Id: gpos_27.c,v 1.36 2004/02/27 20:41:47 marka Exp $ */ /* reviewed: Wed Mar 15 16:48:45 PST 2000 by brister */ @@ -36,7 +36,7 @@ fromtext_gpos(ARGS_FROMTEXT) { UNUSED(type); UNUSED(rdclass); UNUSED(origin); - UNUSED(downcase); + UNUSED(options); UNUSED(callbacks); for (i = 0; i < 3; i++) { @@ -78,7 +78,7 @@ fromwire_gpos(ARGS_FROMWIRE) { UNUSED(type); UNUSED(dctx); UNUSED(rdclass); - UNUSED(downcase); + UNUSED(options); for (i = 0; i < 3; i++) RETERR(txt_fromwire(source, target)); @@ -224,4 +224,29 @@ digest_gpos(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_gpos(ARGS_CHECKOWNER) { + + REQUIRE(type == 27); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_gpos(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 27); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_GPOS_27_C */ diff --git a/lib/dns/rdata/generic/hinfo_13.c b/lib/dns/rdata/generic/hinfo_13.c index d5e03ef85de..9dc8825c6e4 100644 --- a/lib/dns/rdata/generic/hinfo_13.c +++ b/lib/dns/rdata/generic/hinfo_13.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: hinfo_13.c,v 1.40 2002/02/20 03:34:48 marka Exp $ */ +/* $Id: hinfo_13.c,v 1.41 2004/02/27 20:41:47 marka Exp $ */ /* * Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley. @@ -34,7 +34,7 @@ fromtext_hinfo(ARGS_FROMTEXT) { UNUSED(type); UNUSED(rdclass); UNUSED(origin); - UNUSED(downcase); + UNUSED(options); UNUSED(callbacks); REQUIRE(type == 13); @@ -71,7 +71,7 @@ fromwire_hinfo(ARGS_FROMWIRE) { UNUSED(type); UNUSED(dctx); UNUSED(rdclass); - UNUSED(downcase); + UNUSED(options); RETERR(txt_fromwire(source, target)); return (txt_fromwire(source, target)); @@ -196,4 +196,29 @@ digest_hinfo(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_hinfo(ARGS_CHECKOWNER) { + + REQUIRE(type == 13); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_hinfo(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 13); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_HINFO_13_C */ diff --git a/lib/dns/rdata/generic/isdn_20.c b/lib/dns/rdata/generic/isdn_20.c index cfd6983b388..5d96f73fb89 100644 --- a/lib/dns/rdata/generic/isdn_20.c +++ b/lib/dns/rdata/generic/isdn_20.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: isdn_20.c,v 1.32 2002/02/20 03:34:50 marka Exp $ */ +/* $Id: isdn_20.c,v 1.33 2004/02/27 20:41:47 marka Exp $ */ /* Reviewed: Wed Mar 15 16:53:11 PST 2000 by bwelling */ @@ -35,7 +35,7 @@ fromtext_isdn(ARGS_FROMTEXT) { UNUSED(type); UNUSED(rdclass); UNUSED(origin); - UNUSED(downcase); + UNUSED(options); UNUSED(callbacks); /* ISDN-address */ @@ -79,7 +79,7 @@ fromwire_isdn(ARGS_FROMWIRE) { UNUSED(type); UNUSED(dctx); UNUSED(rdclass); - UNUSED(downcase); + UNUSED(options); RETERR(txt_fromwire(source, target)); if (buffer_empty(source)) @@ -206,4 +206,29 @@ digest_isdn(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_isdn(ARGS_CHECKOWNER) { + + REQUIRE(type == 20); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_isdn(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 20); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_ISDN_20_C */ diff --git a/lib/dns/rdata/generic/key_25.c b/lib/dns/rdata/generic/key_25.c index df26d53959e..e509c62bcb4 100644 --- a/lib/dns/rdata/generic/key_25.c +++ b/lib/dns/rdata/generic/key_25.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: key_25.c,v 1.45 2003/09/30 05:56:17 marka Exp $ */ +/* $Id: key_25.c,v 1.46 2004/02/27 20:41:47 marka Exp $ */ /* * Reviewed: Wed Mar 15 16:47:10 PST 2000 by halley. @@ -42,7 +42,7 @@ fromtext_key(ARGS_FROMTEXT) { UNUSED(type); UNUSED(rdclass); UNUSED(origin); - UNUSED(downcase); + UNUSED(options); UNUSED(callbacks); /* flags */ @@ -140,7 +140,7 @@ fromwire_key(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); UNUSED(dctx); - UNUSED(downcase); + UNUSED(options); isc_buffer_activeregion(source, &sr); if (sr.length < 4) @@ -284,4 +284,29 @@ digest_key(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_key(ARGS_CHECKOWNER) { + + REQUIRE(type == 25); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_key(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 25); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_KEY_25_C */ diff --git a/lib/dns/rdata/generic/loc_29.c b/lib/dns/rdata/generic/loc_29.c index 0150541de21..98b5d262577 100644 --- a/lib/dns/rdata/generic/loc_29.c +++ b/lib/dns/rdata/generic/loc_29.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: loc_29.c,v 1.39 2003/07/25 00:01:08 marka Exp $ */ +/* $Id: loc_29.c,v 1.40 2004/02/27 20:41:47 marka Exp $ */ /* Reviewed: Wed Mar 15 18:13:09 PST 2000 by explorer */ @@ -55,7 +55,7 @@ fromtext_loc(ARGS_FROMTEXT) { UNUSED(type); UNUSED(rdclass); UNUSED(origin); - UNUSED(downcase); + UNUSED(options); /* * Defaults. @@ -563,7 +563,7 @@ fromwire_loc(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); UNUSED(dctx); - UNUSED(downcase); + UNUSED(options); isc_buffer_activeregion(source, &sr); if (sr.length < 1) @@ -766,4 +766,29 @@ digest_loc(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_loc(ARGS_CHECKOWNER) { + + REQUIRE(type == 29); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_loc(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 29); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_LOC_29_C */ diff --git a/lib/dns/rdata/generic/mb_7.c b/lib/dns/rdata/generic/mb_7.c index 6236b69f485..ccf926950a9 100644 --- a/lib/dns/rdata/generic/mb_7.c +++ b/lib/dns/rdata/generic/mb_7.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: mb_7.c,v 1.41 2001/07/16 03:06:11 marka Exp $ */ +/* $Id: mb_7.c,v 1.42 2004/02/27 20:41:47 marka Exp $ */ /* Reviewed: Wed Mar 15 17:31:26 PST 2000 by bwelling */ @@ -42,7 +42,7 @@ fromtext_mb(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); return (ISC_R_SUCCESS); } @@ -79,7 +79,7 @@ fromwire_mb(ARGS_FROMWIRE) { dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); dns_name_init(&name, NULL); - return (dns_name_fromwire(&name, source, dctx, downcase, target)); + return (dns_name_fromwire(&name, source, dctx, options, target)); } static inline isc_result_t @@ -207,4 +207,28 @@ digest_mb(ARGS_DIGEST) { return (dns_name_digest(&name, digest, arg)); } +static inline isc_boolean_t +checkowner_mb(ARGS_CHECKOWNER) { + + REQUIRE(type == 7); + + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (dns_name_ismailbox(name)); +} + +static inline isc_boolean_t +checknames_mb(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 7); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_MB_7_C */ diff --git a/lib/dns/rdata/generic/md_3.c b/lib/dns/rdata/generic/md_3.c index fc9dffe1f6a..0563cb1e385 100644 --- a/lib/dns/rdata/generic/md_3.c +++ b/lib/dns/rdata/generic/md_3.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: md_3.c,v 1.43 2001/07/16 03:06:13 marka Exp $ */ +/* $Id: md_3.c,v 1.44 2004/02/27 20:41:48 marka Exp $ */ /* Reviewed: Wed Mar 15 17:48:20 PST 2000 by bwelling */ @@ -42,7 +42,7 @@ fromtext_md(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); return (ISC_R_SUCCESS); } @@ -79,7 +79,7 @@ fromwire_md(ARGS_FROMWIRE) { dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); dns_name_init(&name, NULL); - return (dns_name_fromwire(&name, source, dctx, downcase, target)); + return (dns_name_fromwire(&name, source, dctx, options, target)); } static inline isc_result_t @@ -208,4 +208,29 @@ digest_md(ARGS_DIGEST) { return (dns_name_digest(&name, digest, arg)); } +static inline isc_boolean_t +checkowner_md(ARGS_CHECKOWNER) { + + REQUIRE(type == 3); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_md(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 3); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_MD_3_C */ diff --git a/lib/dns/rdata/generic/mf_4.c b/lib/dns/rdata/generic/mf_4.c index 250c94a7f1f..0dcff9db6b0 100644 --- a/lib/dns/rdata/generic/mf_4.c +++ b/lib/dns/rdata/generic/mf_4.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: mf_4.c,v 1.41 2001/07/16 03:06:14 marka Exp $ */ +/* $Id: mf_4.c,v 1.42 2004/02/27 20:41:48 marka Exp $ */ /* reviewed: Wed Mar 15 17:47:33 PST 2000 by brister */ @@ -42,7 +42,7 @@ fromtext_mf(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); return (ISC_R_SUCCESS); } @@ -79,7 +79,7 @@ fromwire_mf(ARGS_FROMWIRE) { dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); dns_name_init(&name, NULL); - return (dns_name_fromwire(&name, source, dctx, downcase, target)); + return (dns_name_fromwire(&name, source, dctx, options, target)); } static inline isc_result_t @@ -207,4 +207,29 @@ digest_mf(ARGS_DIGEST) { return (dns_name_digest(&name, digest, arg)); } +static inline isc_boolean_t +checkowner_mf(ARGS_CHECKOWNER) { + + REQUIRE(type == 4); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_mf(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 4); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_MF_4_C */ diff --git a/lib/dns/rdata/generic/mg_8.c b/lib/dns/rdata/generic/mg_8.c index 4c634a7fb1a..5d77ab3284b 100644 --- a/lib/dns/rdata/generic/mg_8.c +++ b/lib/dns/rdata/generic/mg_8.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: mg_8.c,v 1.39 2001/07/16 03:06:15 marka Exp $ */ +/* $Id: mg_8.c,v 1.40 2004/02/27 20:41:48 marka Exp $ */ /* reviewed: Wed Mar 15 17:49:21 PST 2000 by brister */ @@ -42,7 +42,7 @@ fromtext_mg(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); return (ISC_R_SUCCESS); } @@ -79,7 +79,7 @@ fromwire_mg(ARGS_FROMWIRE) { dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); dns_name_init(&name, NULL); - return (dns_name_fromwire(&name, source, dctx, downcase, target)); + return (dns_name_fromwire(&name, source, dctx, options, target)); } static inline isc_result_t @@ -203,4 +203,28 @@ digest_mg(ARGS_DIGEST) { return (dns_name_digest(&name, digest, arg)); } +static inline isc_boolean_t +checkowner_mg(ARGS_CHECKOWNER) { + + REQUIRE(type == 8); + + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (dns_name_ismailbox(name)); +} + +static inline isc_boolean_t +checknames_mg(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 8); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_MG_8_C */ diff --git a/lib/dns/rdata/generic/minfo_14.c b/lib/dns/rdata/generic/minfo_14.c index ba1df8c828f..1b98db73ecb 100644 --- a/lib/dns/rdata/generic/minfo_14.c +++ b/lib/dns/rdata/generic/minfo_14.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: minfo_14.c,v 1.41 2001/11/27 00:56:02 gson Exp $ */ +/* $Id: minfo_14.c,v 1.42 2004/02/27 20:41:48 marka Exp $ */ /* reviewed: Wed Mar 15 17:45:32 PST 2000 by brister */ @@ -30,6 +30,7 @@ fromtext_minfo(ARGS_FROMTEXT) { dns_name_t name; isc_buffer_t buffer; int i; + isc_boolean_t ok; REQUIRE(type == 14); @@ -45,7 +46,14 @@ fromtext_minfo(ARGS_FROMTEXT) { buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; RETTOK(dns_name_fromtext(&name, &buffer, origin, - downcase, target)); + options, target)); + ok = ISC_TRUE; + if ((options & DNS_RDATA_CHECKNAMES) != 0) + ok = dns_name_ismailbox(&name); + if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) + RETTOK(DNS_R_BADNAME); + if (!ok && callbacks != NULL) + warn_badname(&name, lexer, callbacks); } return (ISC_R_SUCCESS); } @@ -98,8 +106,8 @@ fromwire_minfo(ARGS_FROMWIRE) { dns_name_init(&rmail, NULL); dns_name_init(&email, NULL); - RETERR(dns_name_fromwire(&rmail, source, dctx, downcase, target)); - return (dns_name_fromwire(&email, source, dctx, downcase, target)); + RETERR(dns_name_fromwire(&rmail, source, dctx, options, target)); + return (dns_name_fromwire(&email, source, dctx, options, target)); } static inline isc_result_t @@ -273,4 +281,44 @@ digest_minfo(ARGS_DIGEST) { return (dns_name_digest(&name, digest, arg)); } +static inline isc_boolean_t +checkowner_minfo(ARGS_CHECKOWNER) { + + REQUIRE(type == 14); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_minfo(ARGS_CHECKNAMES) { + isc_region_t region; + dns_name_t name; + + REQUIRE(rdata->type == 14); + + UNUSED(owner); + + dns_rdata_toregion(rdata, ®ion); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, ®ion); + if (!dns_name_ismailbox(&name)) { + if (bad != NULL) + dns_name_clone(&name, bad); + return (ISC_FALSE); + } + isc_region_consume(®ion, name_length(&name)); + dns_name_fromregion(&name, ®ion); + if (!dns_name_ismailbox(&name)) { + if (bad != NULL) + dns_name_clone(&name, bad); + return (ISC_FALSE); + } + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_MINFO_14_C */ diff --git a/lib/dns/rdata/generic/mr_9.c b/lib/dns/rdata/generic/mr_9.c index 7c11a430154..99c87516400 100644 --- a/lib/dns/rdata/generic/mr_9.c +++ b/lib/dns/rdata/generic/mr_9.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: mr_9.c,v 1.38 2001/07/16 03:06:18 marka Exp $ */ +/* $Id: mr_9.c,v 1.39 2004/02/27 20:41:48 marka Exp $ */ /* Reviewed: Wed Mar 15 21:30:35 EST 2000 by tale */ @@ -42,7 +42,7 @@ fromtext_mr(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); return (ISC_R_SUCCESS); } @@ -79,7 +79,7 @@ fromwire_mr(ARGS_FROMWIRE) { dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); dns_name_init(&name, NULL); - return (dns_name_fromwire(&name, source, dctx, downcase, target)); + return (dns_name_fromwire(&name, source, dctx, options, target)); } static inline isc_result_t @@ -203,4 +203,29 @@ digest_mr(ARGS_DIGEST) { return (dns_name_digest(&name, digest, arg)); } +static inline isc_boolean_t +checkowner_mr(ARGS_CHECKOWNER) { + + REQUIRE(type == 9); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_mr(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 9); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_MR_9_C */ diff --git a/lib/dns/rdata/generic/mx_15.c b/lib/dns/rdata/generic/mx_15.c index a94c94ed572..d0b15b9ef01 100644 --- a/lib/dns/rdata/generic/mx_15.c +++ b/lib/dns/rdata/generic/mx_15.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: mx_15.c,v 1.50 2003/07/25 00:01:08 marka Exp $ */ +/* $Id: mx_15.c,v 1.51 2004/02/27 20:41:48 marka Exp $ */ /* reviewed: Wed Mar 15 18:05:46 PST 2000 by brister */ @@ -29,6 +29,7 @@ fromtext_mx(ARGS_FROMTEXT) { isc_token_t token; dns_name_t name; isc_buffer_t buffer; + isc_boolean_t ok; REQUIRE(type == 15); @@ -47,7 +48,14 @@ fromtext_mx(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); + ok = ISC_TRUE; + if ((options & DNS_RDATA_CHECKNAMES) != 0) + ok = dns_name_ishostname(&name, ISC_FALSE); + if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) + RETTOK(DNS_R_BADNAME); + if (!ok && callbacks != NULL) + warn_badname(&name, lexer, callbacks); return (ISC_R_SUCCESS); } @@ -98,7 +106,7 @@ fromwire_mx(ARGS_FROMWIRE) { return (ISC_R_UNEXPECTEDEND); RETERR(mem_tobuffer(target, sregion.base, 2)); isc_buffer_forward(source, 2); - return (dns_name_fromwire(&name, source, dctx, downcase, target)); + return (dns_name_fromwire(&name, source, dctx, options, target)); } static inline isc_result_t @@ -245,4 +253,36 @@ digest_mx(ARGS_DIGEST) { return (dns_name_digest(&name, digest, arg)); } +static inline isc_boolean_t +checkowner_mx(ARGS_CHECKOWNER) { + + REQUIRE(type == 15); + + UNUSED(type); + UNUSED(rdclass); + + return (dns_name_ishostname(name, wildcard)); +} + +static inline isc_boolean_t +checknames_mx(ARGS_CHECKNAMES) { + isc_region_t region; + dns_name_t name; + + REQUIRE(rdata->type == 15); + + UNUSED(owner); + + dns_rdata_toregion(rdata, ®ion); + isc_region_consume(®ion, 2); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, ®ion); + if (!dns_name_ishostname(&name, ISC_FALSE)) { + if (bad != NULL) + dns_name_clone(&name, bad); + return (ISC_FALSE); + } + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_MX_15_C */ diff --git a/lib/dns/rdata/generic/ns_2.c b/lib/dns/rdata/generic/ns_2.c index 64516c95e0a..4e635518974 100644 --- a/lib/dns/rdata/generic/ns_2.c +++ b/lib/dns/rdata/generic/ns_2.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ns_2.c,v 1.42 2001/07/16 03:06:20 marka Exp $ */ +/* $Id: ns_2.c,v 1.43 2004/02/27 20:41:48 marka Exp $ */ /* Reviewed: Wed Mar 15 18:15:00 PST 2000 by bwelling */ @@ -29,6 +29,7 @@ fromtext_ns(ARGS_FROMTEXT) { isc_token_t token; dns_name_t name; isc_buffer_t buffer; + isc_boolean_t ok; REQUIRE(type == 2); @@ -42,7 +43,14 @@ fromtext_ns(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); + ok = ISC_TRUE; + if ((options & DNS_RDATA_CHECKNAMES) != 0) + ok = dns_name_ishostname(&name, ISC_FALSE); + if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) + RETTOK(DNS_R_BADNAME); + if (!ok && callbacks != NULL) + warn_badname(&name, lexer, callbacks); return (ISC_R_SUCCESS); } @@ -79,7 +87,7 @@ fromwire_ns(ARGS_FROMWIRE) { dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); dns_name_init(&name, NULL); - return (dns_name_fromwire(&name, source, dctx, downcase, target)); + return (dns_name_fromwire(&name, source, dctx, options, target)); } static inline isc_result_t @@ -207,4 +215,37 @@ digest_ns(ARGS_DIGEST) { return (dns_name_digest(&name, digest, arg)); } +static inline isc_boolean_t +checkowner_ns(ARGS_CHECKOWNER) { + + REQUIRE(type == 2); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_ns(ARGS_CHECKNAMES) { + isc_region_t region; + dns_name_t name; + + REQUIRE(rdata->type == 2); + + UNUSED(owner); + + dns_rdata_toregion(rdata, ®ion); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, ®ion); + if (!dns_name_ishostname(&name, ISC_FALSE)) { + if (bad != NULL) + dns_name_clone(&name, bad); + return (ISC_FALSE); + } + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_NS_2_C */ diff --git a/lib/dns/rdata/generic/nsec_47.c b/lib/dns/rdata/generic/nsec_47.c index 1d09d5890ea..c2f54c267db 100644 --- a/lib/dns/rdata/generic/nsec_47.c +++ b/lib/dns/rdata/generic/nsec_47.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nsec_47.c,v 1.5 2003/12/13 04:33:53 marka Exp $ */ +/* $Id: nsec_47.c,v 1.6 2004/02/27 20:41:48 marka Exp $ */ /* reviewed: Wed Mar 15 18:21:15 PST 2000 by brister */ @@ -54,7 +54,7 @@ fromtext_nsec(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); memset(bm, 0, sizeof(bm)); do { @@ -150,7 +150,7 @@ fromwire_nsec(ARGS_FROMWIRE) { dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE); dns_name_init(&name, NULL); - RETERR(dns_name_fromwire(&name, source, dctx, downcase, target)); + RETERR(dns_name_fromwire(&name, source, dctx, options, target)); isc_buffer_activeregion(source, &sr); for (i = 0; i < sr.length; i += len) { @@ -338,4 +338,29 @@ digest_nsec(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_nsec(ARGS_CHECKOWNER) { + + REQUIRE(type == 47); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_nsec(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 47); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_NSEC_47_C */ diff --git a/lib/dns/rdata/generic/null_10.c b/lib/dns/rdata/generic/null_10.c index 61872cb7516..2c5ef9c024d 100644 --- a/lib/dns/rdata/generic/null_10.c +++ b/lib/dns/rdata/generic/null_10.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: null_10.c,v 1.38 2002/02/20 03:34:53 marka Exp $ */ +/* $Id: null_10.c,v 1.39 2004/02/27 20:41:48 marka Exp $ */ /* Reviewed: Thu Mar 16 13:57:50 PST 2000 by explorer */ @@ -32,7 +32,7 @@ fromtext_null(ARGS_FROMTEXT) { UNUSED(type); UNUSED(lexer); UNUSED(origin); - UNUSED(downcase); + UNUSED(options); UNUSED(target); UNUSED(callbacks); @@ -59,7 +59,7 @@ fromwire_null(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); UNUSED(dctx); - UNUSED(downcase); + UNUSED(options); isc_buffer_activeregion(source, &sr); isc_buffer_forward(source, sr.length); @@ -164,4 +164,29 @@ digest_null(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_null(ARGS_CHECKOWNER) { + + REQUIRE(type == 10); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_null(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 10); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_NULL_10_C */ diff --git a/lib/dns/rdata/generic/nxt_30.c b/lib/dns/rdata/generic/nxt_30.c index 132e4535da2..d17d128a1d6 100644 --- a/lib/dns/rdata/generic/nxt_30.c +++ b/lib/dns/rdata/generic/nxt_30.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nxt_30.c,v 1.57 2003/09/30 05:56:17 marka Exp $ */ +/* $Id: nxt_30.c,v 1.58 2004/02/27 20:41:48 marka Exp $ */ /* reviewed: Wed Mar 15 18:21:15 PST 2000 by brister */ @@ -56,7 +56,7 @@ fromtext_nxt(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); memset(bm, 0, sizeof(bm)); do { @@ -139,7 +139,7 @@ fromwire_nxt(ARGS_FROMWIRE) { dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE); dns_name_init(&name, NULL); - RETERR(dns_name_fromwire(&name, source, dctx, downcase, target)); + RETERR(dns_name_fromwire(&name, source, dctx, options, target)); isc_buffer_activeregion(source, &sr); if (sr.length > 0 && (sr.base[0] & 0x80) == 0 && @@ -301,4 +301,29 @@ digest_nxt(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_nxt(ARGS_CHECKOWNER) { + + REQUIRE(type == 30); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_nxt(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 30); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_NXT_30_C */ diff --git a/lib/dns/rdata/generic/opt_41.c b/lib/dns/rdata/generic/opt_41.c index e399c781094..a3327824bd0 100644 --- a/lib/dns/rdata/generic/opt_41.c +++ b/lib/dns/rdata/generic/opt_41.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: opt_41.c,v 1.27 2002/02/20 03:34:57 marka Exp $ */ +/* $Id: opt_41.c,v 1.28 2004/02/27 20:41:48 marka Exp $ */ /* Reviewed: Thu Mar 16 14:06:44 PST 2000 by gson */ @@ -40,7 +40,7 @@ fromtext_opt(ARGS_FROMTEXT) { UNUSED(rdclass); UNUSED(lexer); UNUSED(origin); - UNUSED(downcase); + UNUSED(options); UNUSED(target); UNUSED(callbacks); @@ -101,7 +101,7 @@ fromwire_opt(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); UNUSED(dctx); - UNUSED(downcase); + UNUSED(options); isc_buffer_activeregion(source, &sregion); total = 0; @@ -253,4 +253,28 @@ digest_opt(ARGS_DIGEST) { return (ISC_R_NOTIMPLEMENTED); } +static inline isc_boolean_t +checkowner_opt(ARGS_CHECKOWNER) { + + REQUIRE(type == 41); + + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (dns_name_equal(name, dns_rootname)); +} + +static inline isc_boolean_t +checknames_opt(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 41); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_OPT_41_C */ diff --git a/lib/dns/rdata/generic/proforma.c b/lib/dns/rdata/generic/proforma.c index 28c2ce02984..9478e35c152 100644 --- a/lib/dns/rdata/generic/proforma.c +++ b/lib/dns/rdata/generic/proforma.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: proforma.c,v 1.32 2002/02/20 03:34:59 marka Exp $ */ +/* $Id: proforma.c,v 1.33 2004/02/27 20:41:48 marka Exp $ */ #ifndef RDATA_GENERIC_#_#_C #define RDATA_GENERIC_#_#_C @@ -143,4 +143,31 @@ digest_#(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_#(ARGS_CHECKOWNER) { + + REQUIRE(type == #); + REQUIRE(rdclass == #); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_#(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == #); + REQUIRE(rdata->rdclass == #); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_#_#_C */ diff --git a/lib/dns/rdata/generic/ptr_12.c b/lib/dns/rdata/generic/ptr_12.c index 9fccd5b91fe..f77f8ae999b 100644 --- a/lib/dns/rdata/generic/ptr_12.c +++ b/lib/dns/rdata/generic/ptr_12.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: ptr_12.c,v 1.39 2001/07/16 03:06:26 marka Exp $ */ +/* $Id: ptr_12.c,v 1.40 2004/02/27 20:41:48 marka Exp $ */ /* Reviewed: Thu Mar 16 14:05:12 PST 2000 by explorer */ @@ -42,7 +42,17 @@ fromtext_ptr(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); + if (rdclass == dns_rdataclass_in && + (options & DNS_RDATA_CHECKNAMES) != 0 && + (options & DNS_RDATA_CHECKREVERSE) != 0) { + isc_boolean_t ok; + ok = dns_name_ishostname(&name, ISC_FALSE); + if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) + RETTOK(DNS_R_BADNAME); + if (!ok && callbacks != NULL) + warn_badname(&name, lexer, callbacks); + } return (ISC_R_SUCCESS); } @@ -79,7 +89,7 @@ fromwire_ptr(ARGS_FROMWIRE) { dns_decompress_setmethods(dctx, DNS_COMPRESS_GLOBAL14); dns_name_init(&name, NULL); - return (dns_name_fromwire(&name, source, dctx, downcase, target)); + return (dns_name_fromwire(&name, source, dctx, options, target)); } static inline isc_result_t @@ -204,4 +214,78 @@ digest_ptr(ARGS_DIGEST) { return (dns_name_digest(&name, digest, arg)); } +static inline isc_boolean_t +checkowner_ptr(ARGS_CHECKOWNER) { + + REQUIRE(type == 12); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static unsigned char ip6_arpa_data[] = "\003IP6\004ARPA"; +static unsigned char ip6_arpa_offsets[] = { 0, 4, 9 }; +static const dns_name_t ip6_arpa = +{ + DNS_NAME_MAGIC, + ip6_arpa_data, 10, 3, + DNS_NAMEATTR_READONLY | DNS_NAMEATTR_ABSOLUTE, + ip6_arpa_offsets, NULL, + {(void *)-1, (void *)-1}, + {NULL, NULL} +}; + +static unsigned char ip6_int_data[] = "\003IP6\003INT"; +static unsigned char ip6_int_offsets[] = { 0, 4, 8 }; +static const dns_name_t ip6_int = +{ + DNS_NAME_MAGIC, + ip6_int_data, 9, 3, + DNS_NAMEATTR_READONLY | DNS_NAMEATTR_ABSOLUTE, + ip6_int_offsets, NULL, + {(void *)-1, (void *)-1}, + {NULL, NULL} +}; + +static unsigned char in_addr_arpa_data[] = "\007IN-ADDR\004ARPA"; +static unsigned char in_addr_arpa_offsets[] = { 0, 8, 13 }; +static const dns_name_t in_addr_arpa = +{ + DNS_NAME_MAGIC, + in_addr_arpa_data, 14, 3, + DNS_NAMEATTR_READONLY | DNS_NAMEATTR_ABSOLUTE, + in_addr_arpa_offsets, NULL, + {(void *)-1, (void *)-1}, + {NULL, NULL} +}; + +static inline isc_boolean_t +checknames_ptr(ARGS_CHECKNAMES) { + isc_region_t region; + dns_name_t name; + + REQUIRE(rdata->type == 12); + + if (rdata->rdclass != dns_rdataclass_in) + return (ISC_TRUE); + + if (dns_name_issubdomain(owner, &in_addr_arpa) || + dns_name_issubdomain(owner, &ip6_arpa) || + dns_name_issubdomain(owner, &ip6_int)) { + dns_rdata_toregion(rdata, ®ion); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, ®ion); + if (!dns_name_ishostname(&name, ISC_FALSE)) { + if (bad != NULL) + dns_name_clone(&name, bad); + return (ISC_FALSE); + } + } + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_PTR_12_C */ diff --git a/lib/dns/rdata/generic/rp_17.c b/lib/dns/rdata/generic/rp_17.c index 5f7d3dcea08..1f4bad33b4a 100644 --- a/lib/dns/rdata/generic/rp_17.c +++ b/lib/dns/rdata/generic/rp_17.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rp_17.c,v 1.36 2001/11/27 00:56:05 gson Exp $ */ +/* $Id: rp_17.c,v 1.37 2004/02/27 20:41:48 marka Exp $ */ /* RFC 1183 */ @@ -30,6 +30,7 @@ fromtext_rp(ARGS_FROMTEXT) { dns_name_t name; isc_buffer_t buffer; int i; + isc_boolean_t ok; REQUIRE(type == 17); @@ -46,7 +47,14 @@ fromtext_rp(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); RETTOK(dns_name_fromtext(&name, &buffer, origin, - downcase, target)); + options, target)); + ok = ISC_TRUE; + if ((options & DNS_RDATA_CHECKNAMES) != 0 && i == 0) + ok = dns_name_ismailbox(&name); + if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) + RETTOK(DNS_R_BADNAME); + if (!ok && callbacks != NULL) + warn_badname(&name, lexer, callbacks); } return (ISC_R_SUCCESS); } @@ -98,8 +106,8 @@ fromwire_rp(ARGS_FROMWIRE) { dns_name_init(&rmail, NULL); dns_name_init(&email, NULL); - RETERR(dns_name_fromwire(&rmail, source, dctx, downcase, target)); - return (dns_name_fromwire(&email, source, dctx, downcase, target)); + RETERR(dns_name_fromwire(&rmail, source, dctx, options, target)); + return (dns_name_fromwire(&email, source, dctx, options, target)); } static inline isc_result_t @@ -270,4 +278,37 @@ digest_rp(ARGS_DIGEST) { return (dns_name_digest(&name, digest, arg)); } +static inline isc_boolean_t +checkowner_rp(ARGS_CHECKOWNER) { + + REQUIRE(type == 17); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_rp(ARGS_CHECKNAMES) { + isc_region_t region; + dns_name_t name; + + REQUIRE(rdata->type == 17); + + UNUSED(owner); + + dns_rdata_toregion(rdata, ®ion); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, ®ion); + if (!dns_name_ismailbox(&name)) { + if (bad != NULL) + dns_name_clone(&name, bad); + return (ISC_FALSE); + } + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_RP_17_C */ diff --git a/lib/dns/rdata/generic/rrsig_46.c b/lib/dns/rdata/generic/rrsig_46.c index 402a4442742..245563012a4 100644 --- a/lib/dns/rdata/generic/rrsig_46.c +++ b/lib/dns/rdata/generic/rrsig_46.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rrsig_46.c,v 1.2 2003/09/30 06:00:40 marka Exp $ */ +/* $Id: rrsig_46.c,v 1.3 2004/02/27 20:41:48 marka Exp $ */ /* Reviewed: Fri Mar 17 09:05:02 PST 2000 by gson */ @@ -116,7 +116,7 @@ fromtext_rrsig(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); /* * Sig. @@ -267,7 +267,7 @@ fromwire_rrsig(ARGS_FROMWIRE) { * Signer. */ dns_name_init(&name, NULL); - RETERR(dns_name_fromwire(&name, source, dctx, downcase, target)); + RETERR(dns_name_fromwire(&name, source, dctx, options, target)); /* * Sig. @@ -523,4 +523,29 @@ covers_rrsig(dns_rdata_t *rdata) { return (type); } +static inline isc_boolean_t +checkowner_rrsig(ARGS_CHECKOWNER) { + + REQUIRE(type == 46); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_rrsig(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 46); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_RRSIG_46_C */ diff --git a/lib/dns/rdata/generic/rt_21.c b/lib/dns/rdata/generic/rt_21.c index 767207c7890..a43c4c2a032 100644 --- a/lib/dns/rdata/generic/rt_21.c +++ b/lib/dns/rdata/generic/rt_21.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rt_21.c,v 1.39 2003/07/25 00:01:08 marka Exp $ */ +/* $Id: rt_21.c,v 1.40 2004/02/27 20:41:49 marka Exp $ */ /* reviewed: Thu Mar 16 15:02:31 PST 2000 by brister */ @@ -31,6 +31,7 @@ fromtext_rt(ARGS_FROMTEXT) { isc_token_t token; dns_name_t name; isc_buffer_t buffer; + isc_boolean_t ok; REQUIRE(type == 21); @@ -50,7 +51,14 @@ fromtext_rt(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); + ok = ISC_TRUE; + if ((options & DNS_RDATA_CHECKNAMES) != 0) + ok = dns_name_ishostname(&name, ISC_FALSE); + if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) + RETTOK(DNS_R_BADNAME); + if (!ok && callbacks != NULL) + warn_badname(&name, lexer, callbacks); return (ISC_R_SUCCESS); } @@ -104,7 +112,7 @@ fromwire_rt(ARGS_FROMWIRE) { memcpy(tregion.base, sregion.base, 2); isc_buffer_forward(source, 2); isc_buffer_add(target, 2); - return (dns_name_fromwire(&name, source, dctx, downcase, target)); + return (dns_name_fromwire(&name, source, dctx, options, target)); } static inline isc_result_t @@ -266,4 +274,38 @@ digest_rt(ARGS_DIGEST) { return (dns_name_digest(&name, digest, arg)); } +static inline isc_boolean_t +checkowner_rt(ARGS_CHECKOWNER) { + + REQUIRE(type == 21); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_rt(ARGS_CHECKNAMES) { + isc_region_t region; + dns_name_t name; + + REQUIRE(rdata->type == 21); + + UNUSED(owner); + + dns_rdata_toregion(rdata, ®ion); + isc_region_consume(®ion, 2); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, ®ion); + if (dns_name_ishostname(&name, ISC_FALSE)) { + if (bad != NULL) + dns_name_clone(&name, bad); + return (ISC_FALSE); + } + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_RT_21_C */ diff --git a/lib/dns/rdata/generic/sig_24.c b/lib/dns/rdata/generic/sig_24.c index 587ac2bd170..9eeaf9bb655 100644 --- a/lib/dns/rdata/generic/sig_24.c +++ b/lib/dns/rdata/generic/sig_24.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: sig_24.c,v 1.60 2003/09/30 05:56:18 marka Exp $ */ +/* $Id: sig_24.c,v 1.61 2004/02/27 20:41:49 marka Exp $ */ /* Reviewed: Fri Mar 17 09:05:02 PST 2000 by gson */ @@ -116,7 +116,7 @@ fromtext_sig(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); /* * Sig. @@ -267,7 +267,7 @@ fromwire_sig(ARGS_FROMWIRE) { * Signer. */ dns_name_init(&name, NULL); - RETERR(dns_name_fromwire(&name, source, dctx, downcase, target)); + RETERR(dns_name_fromwire(&name, source, dctx, options, target)); /* * Sig. @@ -550,4 +550,29 @@ covers_sig(dns_rdata_t *rdata) { return (type); } +static inline isc_boolean_t +checkowner_sig(ARGS_CHECKOWNER) { + + REQUIRE(type == 24); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_sig(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 24); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_SIG_24_C */ diff --git a/lib/dns/rdata/generic/soa_6.c b/lib/dns/rdata/generic/soa_6.c index d3be4b28aed..f16f06efa8d 100644 --- a/lib/dns/rdata/generic/soa_6.c +++ b/lib/dns/rdata/generic/soa_6.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: soa_6.c,v 1.57 2002/02/20 03:35:01 marka Exp $ */ +/* $Id: soa_6.c,v 1.58 2004/02/27 20:41:49 marka Exp $ */ /* Reviewed: Thu Mar 16 15:18:32 PST 2000 by explorer */ @@ -31,6 +31,7 @@ fromtext_soa(ARGS_FROMTEXT) { isc_buffer_t buffer; int i; isc_uint32_t n; + isc_boolean_t ok; REQUIRE(type == 6); @@ -48,7 +49,22 @@ fromtext_soa(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); RETTOK(dns_name_fromtext(&name, &buffer, origin, - downcase, target)); + options, target)); + ok = ISC_TRUE; + if ((options & DNS_RDATA_CHECKNAMES) != 0) + switch (i) { + case 0: + ok = dns_name_ishostname(&name, ISC_FALSE); + break; + case 1: + ok = dns_name_ismailbox(&name); + break; + + } + if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) + RETTOK(DNS_R_BADNAME); + if (!ok && callbacks != NULL) + warn_badname(&name, lexer, callbacks); } RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_number, @@ -158,8 +174,8 @@ fromwire_soa(ARGS_FROMWIRE) { dns_name_init(&mname, NULL); dns_name_init(&rname, NULL); - RETERR(dns_name_fromwire(&mname, source, dctx, downcase, target)); - RETERR(dns_name_fromwire(&rname, source, dctx, downcase, target)); + RETERR(dns_name_fromwire(&mname, source, dctx, options, target)); + RETERR(dns_name_fromwire(&rname, source, dctx, options, target)); isc_buffer_activeregion(source, &sregion); isc_buffer_availableregion(target, &tregion); @@ -384,4 +400,44 @@ digest_soa(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_soa(ARGS_CHECKOWNER) { + + REQUIRE(type == 6); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_soa(ARGS_CHECKNAMES) { + isc_region_t region; + dns_name_t name; + + REQUIRE(rdata->type == 6); + + UNUSED(owner); + + dns_rdata_toregion(rdata, ®ion); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, ®ion); + if (!dns_name_ishostname(&name, ISC_FALSE)) { + if (bad != NULL) + dns_name_clone(&name, bad); + return (ISC_FALSE); + } + isc_region_consume(®ion, name_length(&name)); + dns_name_fromregion(&name, ®ion); + if (!dns_name_ismailbox(&name)) { + if (bad != NULL) + dns_name_clone(&name, bad); + return (ISC_FALSE); + } + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_SOA_6_C */ diff --git a/lib/dns/rdata/generic/sshfp_44.c b/lib/dns/rdata/generic/sshfp_44.c index 5eb93a5fed7..defb56bfd29 100644 --- a/lib/dns/rdata/generic/sshfp_44.c +++ b/lib/dns/rdata/generic/sshfp_44.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: sshfp_44.c,v 1.1 2003/10/01 10:05:00 marka Exp $ */ +/* $Id: sshfp_44.c,v 1.2 2004/02/27 20:41:49 marka Exp $ */ /* draft-ietf-secsh-dns-05.txt */ @@ -33,7 +33,7 @@ fromtext_sshfp(ARGS_FROMTEXT) { UNUSED(type); UNUSED(rdclass); UNUSED(origin); - UNUSED(downcase); + UNUSED(options); UNUSED(callbacks); /* @@ -111,7 +111,7 @@ fromwire_sshfp(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); UNUSED(dctx); - UNUSED(downcase); + UNUSED(options); isc_buffer_activeregion(source, &sr); if (sr.length < 4) @@ -234,4 +234,29 @@ digest_sshfp(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_sshfp(ARGS_CHECKOWNER) { + + REQUIRE(type == 44); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_sshfp(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 44); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_SSHFP_44_C */ diff --git a/lib/dns/rdata/generic/tkey_249.c b/lib/dns/rdata/generic/tkey_249.c index 79c911ec219..dd9cd4a2764 100644 --- a/lib/dns/rdata/generic/tkey_249.c +++ b/lib/dns/rdata/generic/tkey_249.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: tkey_249.c,v 1.53 2003/07/25 00:01:09 marka Exp $ */ +/* $Id: tkey_249.c,v 1.54 2004/02/27 20:41:49 marka Exp $ */ /* * Reviewed: Thu Mar 16 17:35:30 PST 2000 by halley. @@ -51,7 +51,7 @@ fromtext_tkey(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); /* @@ -252,7 +252,7 @@ fromwire_tkey(ARGS_FROMWIRE) { * Algorithm. */ dns_name_init(&name, NULL); - RETERR(dns_name_fromwire(&name, source, dctx, downcase, target)); + RETERR(dns_name_fromwire(&name, source, dctx, options, target)); /* * Inception: 4 @@ -527,4 +527,29 @@ digest_tkey(ARGS_DIGEST) { return (ISC_R_NOTIMPLEMENTED); } +static inline isc_boolean_t +checkowner_tkey(ARGS_CHECKOWNER) { + + REQUIRE(type == 249); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_tkey(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 249); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_TKEY_249_C */ diff --git a/lib/dns/rdata/generic/txt_16.c b/lib/dns/rdata/generic/txt_16.c index 443a2eb4b0a..741d3eba6d8 100644 --- a/lib/dns/rdata/generic/txt_16.c +++ b/lib/dns/rdata/generic/txt_16.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: txt_16.c,v 1.39 2002/02/20 03:35:04 marka Exp $ */ +/* $Id: txt_16.c,v 1.40 2004/02/27 20:41:49 marka Exp $ */ /* Reviewed: Thu Mar 16 15:40:00 PST 2000 by bwelling */ @@ -34,7 +34,7 @@ fromtext_txt(ARGS_FROMTEXT) { UNUSED(type); UNUSED(rdclass); UNUSED(origin); - UNUSED(downcase); + UNUSED(options); UNUSED(callbacks); strings = 0; @@ -81,7 +81,7 @@ fromwire_txt(ARGS_FROMWIRE) { UNUSED(type); UNUSED(dctx); UNUSED(rdclass); - UNUSED(downcase); + UNUSED(options); do { result = txt_fromwire(source, target); @@ -210,4 +210,29 @@ digest_txt(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_txt(ARGS_CHECKOWNER) { + + REQUIRE(type == 16); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_txt(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 16); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_TXT_16_C */ diff --git a/lib/dns/rdata/generic/unspec_103.c b/lib/dns/rdata/generic/unspec_103.c index 0efece8cbaf..ecaab704c44 100644 --- a/lib/dns/rdata/generic/unspec_103.c +++ b/lib/dns/rdata/generic/unspec_103.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: unspec_103.c,v 1.31 2002/02/20 03:35:05 marka Exp $ */ +/* $Id: unspec_103.c,v 1.32 2004/02/27 20:41:49 marka Exp $ */ #ifndef RDATA_GENERIC_UNSPEC_103_C #define RDATA_GENERIC_UNSPEC_103_C @@ -30,7 +30,7 @@ fromtext_unspec(ARGS_FROMTEXT) { UNUSED(type); UNUSED(rdclass); UNUSED(origin); - UNUSED(downcase); + UNUSED(options); UNUSED(callbacks); return (atob_tobuffer(lexer, target)); @@ -55,7 +55,7 @@ fromwire_unspec(ARGS_FROMWIRE) { UNUSED(type); UNUSED(rdclass); UNUSED(dctx); - UNUSED(downcase); + UNUSED(options); isc_buffer_activeregion(source, &sr); isc_buffer_forward(source, sr.length); @@ -161,4 +161,29 @@ digest_unspec(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_unspec(ARGS_CHECKOWNER) { + + REQUIRE(type == 103); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_unspec(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 103); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_UNSPEC_103_C */ diff --git a/lib/dns/rdata/generic/x25_19.c b/lib/dns/rdata/generic/x25_19.c index aa56f34030b..6f1c39af887 100644 --- a/lib/dns/rdata/generic/x25_19.c +++ b/lib/dns/rdata/generic/x25_19.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: x25_19.c,v 1.33 2002/02/20 03:35:06 marka Exp $ */ +/* $Id: x25_19.c,v 1.34 2004/02/27 20:41:49 marka Exp $ */ /* Reviewed: Thu Mar 16 16:15:57 PST 2000 by bwelling */ @@ -36,7 +36,7 @@ fromtext_x25(ARGS_FROMTEXT) { UNUSED(type); UNUSED(rdclass); UNUSED(origin); - UNUSED(downcase); + UNUSED(options); UNUSED(callbacks); RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_qstring, @@ -72,7 +72,7 @@ fromwire_x25(ARGS_FROMWIRE) { UNUSED(type); UNUSED(dctx); UNUSED(rdclass); - UNUSED(downcase); + UNUSED(options); isc_buffer_activeregion(source, &sr); if (sr.length < 5) @@ -191,4 +191,29 @@ digest_x25(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_x25(ARGS_CHECKOWNER) { + + REQUIRE(type == 19); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_x25(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 19); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_GENERIC_X25_19_C */ diff --git a/lib/dns/rdata/hs_4/a_1.c b/lib/dns/rdata/hs_4/a_1.c index 783c509e8fe..1a3e6378a55 100644 --- a/lib/dns/rdata/hs_4/a_1.c +++ b/lib/dns/rdata/hs_4/a_1.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: a_1.c,v 1.27 2002/02/20 03:35:08 marka Exp $ */ +/* $Id: a_1.c,v 1.28 2004/02/27 20:41:49 marka Exp $ */ /* reviewed: Thu Mar 16 15:58:36 PST 2000 by brister */ @@ -37,7 +37,7 @@ fromtext_hs_a(ARGS_FROMTEXT) { UNUSED(type); UNUSED(origin); - UNUSED(downcase); + UNUSED(options); UNUSED(rdclass); RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, @@ -77,7 +77,7 @@ fromwire_hs_a(ARGS_FROMWIRE) { UNUSED(type); UNUSED(dctx); - UNUSED(downcase); + UNUSED(options); UNUSED(rdclass); isc_buffer_activeregion(source, &sregion); @@ -202,4 +202,31 @@ digest_hs_a(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_hs_a(ARGS_CHECKOWNER) { + + REQUIRE(type == 1); + REQUIRE(rdclass == 4); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_hs_a(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 1); + REQUIRE(rdata->rdclass == 4); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_HS_4_A_1_C */ diff --git a/lib/dns/rdata/in_1/a6_38.c b/lib/dns/rdata/in_1/a6_38.c index 1ec3532468f..14adb33ab27 100644 --- a/lib/dns/rdata/in_1/a6_38.c +++ b/lib/dns/rdata/in_1/a6_38.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: a6_38.c,v 1.50 2003/07/25 00:01:10 marka Exp $ */ +/* $Id: a6_38.c,v 1.51 2004/02/27 20:41:49 marka Exp $ */ /* RFC2874 */ @@ -35,6 +35,7 @@ fromtext_in_a6(ARGS_FROMTEXT) { unsigned char mask; dns_name_t name; isc_buffer_t buffer; + isc_boolean_t ok; REQUIRE(type == 38); REQUIRE(rdclass == 1); @@ -83,7 +84,14 @@ fromtext_in_a6(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); + ok = ISC_TRUE; + if ((options & DNS_RDATA_CHECKNAMES) != 0) + ok = dns_name_ishostname(&name, ISC_FALSE); + if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) + RETTOK(DNS_R_BADNAME); + if (!ok && callbacks != NULL) + warn_badname(&name, lexer, callbacks); return (ISC_R_SUCCESS); } @@ -180,7 +188,7 @@ fromwire_in_a6(ARGS_FROMWIRE) { return (ISC_R_SUCCESS); dns_name_init(&name, NULL); - return (dns_name_fromwire(&name, source, dctx, downcase, target)); + return (dns_name_fromwire(&name, source, dctx, options, target)); } static inline isc_result_t @@ -412,4 +420,42 @@ digest_in_a6(ARGS_DIGEST) { return (dns_name_digest(&name, digest, arg)); } +static inline isc_boolean_t +checkowner_in_a6(ARGS_CHECKOWNER) { + + REQUIRE(type == 38); + REQUIRE(rdclass == 1); + + UNUSED(type); + UNUSED(rdclass); + + return (dns_name_ishostname(name, wildcard)); +} + +static inline isc_boolean_t +checknames_in_a6(ARGS_CHECKNAMES) { + isc_region_t region; + dns_name_t name; + unsigned int prefixlen; + + REQUIRE(rdata->type == 38); + REQUIRE(rdata->rdclass == 1); + + UNUSED(owner); + + dns_rdata_toregion(rdata, ®ion); + prefixlen = uint8_fromregion(®ion); + if (prefixlen == 0) + return (ISC_TRUE); + isc_region_consume(®ion, 1 + 16 - prefixlen / 8); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, ®ion); + if (!dns_name_ishostname(&name, ISC_FALSE)) { + if (bad != NULL) + dns_name_clone(&name, bad); + return (ISC_FALSE); + } + return (ISC_TRUE); +} + #endif /* RDATA_IN_1_A6_38_C */ diff --git a/lib/dns/rdata/in_1/a_1.c b/lib/dns/rdata/in_1/a_1.c index 43bc6c94ea8..62eff6d38f2 100644 --- a/lib/dns/rdata/in_1/a_1.c +++ b/lib/dns/rdata/in_1/a_1.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: a_1.c,v 1.49 2002/02/20 03:35:10 marka Exp $ */ +/* $Id: a_1.c,v 1.50 2004/02/27 20:41:50 marka Exp $ */ /* Reviewed: Thu Mar 16 16:52:50 PST 2000 by bwelling */ @@ -39,7 +39,7 @@ fromtext_in_a(ARGS_FROMTEXT) { UNUSED(type); UNUSED(origin); - UNUSED(downcase); + UNUSED(options); UNUSED(rdclass); RETERR(isc_lex_getmastertoken(lexer, &token, isc_tokentype_string, @@ -79,7 +79,7 @@ fromwire_in_a(ARGS_FROMWIRE) { UNUSED(type); UNUSED(dctx); - UNUSED(downcase); + UNUSED(options); UNUSED(rdclass); isc_buffer_activeregion(source, &sregion); @@ -208,4 +208,29 @@ digest_in_a(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_in_a(ARGS_CHECKOWNER) { + + REQUIRE(type == 1); + REQUIRE(rdclass == 1); + + UNUSED(type); + UNUSED(rdclass); + + return (dns_name_ishostname(name, wildcard)); +} + +static inline isc_boolean_t +checknames_in_a(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 1); + REQUIRE(rdata->rdclass == 1); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_IN_1_A_1_C */ diff --git a/lib/dns/rdata/in_1/aaaa_28.c b/lib/dns/rdata/in_1/aaaa_28.c index d195db5a60a..e770270dc3f 100644 --- a/lib/dns/rdata/in_1/aaaa_28.c +++ b/lib/dns/rdata/in_1/aaaa_28.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: aaaa_28.c,v 1.39 2002/02/20 03:35:12 marka Exp $ */ +/* $Id: aaaa_28.c,v 1.40 2004/02/27 20:41:50 marka Exp $ */ /* Reviewed: Thu Mar 16 16:52:50 PST 2000 by bwelling */ @@ -39,7 +39,7 @@ fromtext_in_aaaa(ARGS_FROMTEXT) { UNUSED(type); UNUSED(origin); - UNUSED(downcase); + UNUSED(options); UNUSED(rdclass); UNUSED(callbacks); @@ -80,7 +80,7 @@ fromwire_in_aaaa(ARGS_FROMWIRE) { UNUSED(type); UNUSED(dctx); - UNUSED(downcase); + UNUSED(options); UNUSED(rdclass); isc_buffer_activeregion(source, &sregion); @@ -205,4 +205,29 @@ digest_in_aaaa(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_in_aaaa(ARGS_CHECKOWNER) { + + REQUIRE(type == 28); + REQUIRE(rdclass == 1); + + UNUSED(type); + UNUSED(rdclass); + + return (dns_name_ishostname(name, wildcard)); +} + +static inline isc_boolean_t +checknames_in_aaaa(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 28); + REQUIRE(rdata->rdclass == 1); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_IN_1_AAAA_28_C */ diff --git a/lib/dns/rdata/in_1/apl_42.c b/lib/dns/rdata/in_1/apl_42.c index 610a40583a2..37ce91c1b8a 100644 --- a/lib/dns/rdata/in_1/apl_42.c +++ b/lib/dns/rdata/in_1/apl_42.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: apl_42.c,v 1.5 2004/01/05 06:11:39 marka Exp $ */ +/* $Id: apl_42.c,v 1.6 2004/02/27 20:41:50 marka Exp $ */ /* RFC 3123 */ @@ -41,7 +41,7 @@ fromtext_in_apl(ARGS_FROMTEXT) { UNUSED(type); UNUSED(rdclass); UNUSED(origin); - UNUSED(downcase); + UNUSED(options); UNUSED(callbacks); do { @@ -186,7 +186,7 @@ fromwire_in_apl(ARGS_FROMWIRE) { UNUSED(type); UNUSED(dctx); UNUSED(rdclass); - UNUSED(downcase); + UNUSED(options); isc_buffer_activeregion(source, &sr); isc_buffer_availableregion(target, &tr); @@ -371,4 +371,32 @@ digest_in_apl(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_in_apl(ARGS_CHECKOWNER) { + + REQUIRE(type == 42); + REQUIRE(rdclass == 1); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + + +static inline isc_boolean_t +checknames_in_apl(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 42); + REQUIRE(rdata->rdclass == 1); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_IN_1_APL_42_C */ diff --git a/lib/dns/rdata/in_1/kx_36.c b/lib/dns/rdata/in_1/kx_36.c index 2d6952f3cc4..9b423e1169b 100644 --- a/lib/dns/rdata/in_1/kx_36.c +++ b/lib/dns/rdata/in_1/kx_36.c @@ -15,14 +15,14 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: kx_36.c,v 1.39 2003/07/25 00:01:10 marka Exp $ */ +/* $Id: kx_36.c,v 1.40 2004/02/27 20:41:50 marka Exp $ */ /* Reviewed: Thu Mar 16 17:24:54 PST 2000 by explorer */ /* RFC 2230 */ -#ifndef RDATA_GENERIC_KX_36_C -#define RDATA_GENERIC_KX_36_C +#ifndef RDATA_IN_1_KX_36_C +#define RDATA_IN_1_KX_36_C #define RRTYPE_KX_ATTRIBUTES (0) @@ -50,7 +50,7 @@ fromtext_in_kx(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); return (ISC_R_SUCCESS); } @@ -103,7 +103,7 @@ fromwire_in_kx(ARGS_FROMWIRE) { return (ISC_R_UNEXPECTEDEND); RETERR(mem_tobuffer(target, sregion.base, 2)); isc_buffer_forward(source, 2); - return (dns_name_fromwire(&name, source, dctx, downcase, target)); + return (dns_name_fromwire(&name, source, dctx, options, target)); } static inline isc_result_t @@ -258,4 +258,31 @@ digest_in_kx(ARGS_DIGEST) { return (dns_name_digest(&name, digest, arg)); } -#endif /* RDATA_GENERIC_KX_36_C */ +static inline isc_boolean_t +checkowner_in_kx(ARGS_CHECKOWNER) { + + REQUIRE(type == 36); + REQUIRE(rdclass == 1); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_in_kx(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 36); + REQUIRE(rdata->rdclass == 1); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + +#endif /* RDATA_IN_1_KX_36_C */ diff --git a/lib/dns/rdata/in_1/naptr_35.c b/lib/dns/rdata/in_1/naptr_35.c index 6c76496d29a..da66a4bd2aa 100644 --- a/lib/dns/rdata/in_1/naptr_35.c +++ b/lib/dns/rdata/in_1/naptr_35.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: naptr_35.c,v 1.45 2003/07/25 00:01:10 marka Exp $ */ +/* $Id: naptr_35.c,v 1.46 2004/02/27 20:41:50 marka Exp $ */ /* Reviewed: Thu Mar 16 16:52:50 PST 2000 by bwelling */ @@ -86,7 +86,7 @@ fromtext_in_naptr(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); return (ISC_R_SUCCESS); } @@ -194,7 +194,7 @@ fromwire_in_naptr(ARGS_FROMWIRE) { /* * Replacement. */ - return (dns_name_fromwire(&name, source, dctx, downcase, target)); + return (dns_name_fromwire(&name, source, dctx, options, target)); } static inline isc_result_t @@ -548,4 +548,31 @@ digest_in_naptr(ARGS_DIGEST) { return (dns_name_digest(&name, digest, arg)); } +static inline isc_boolean_t +checkowner_in_naptr(ARGS_CHECKOWNER) { + + REQUIRE(type == 35); + REQUIRE(rdclass == 1); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_in_naptr(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 35); + REQUIRE(rdata->rdclass == 1); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_IN_1_NAPTR_35_C */ diff --git a/lib/dns/rdata/in_1/nsap-ptr_23.c b/lib/dns/rdata/in_1/nsap-ptr_23.c index adad651d3ac..a9f123cb684 100644 --- a/lib/dns/rdata/in_1/nsap-ptr_23.c +++ b/lib/dns/rdata/in_1/nsap-ptr_23.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nsap-ptr_23.c,v 1.32 2001/07/16 03:06:46 marka Exp $ */ +/* $Id: nsap-ptr_23.c,v 1.33 2004/02/27 20:41:50 marka Exp $ */ /* Reviewed: Fri Mar 17 10:16:02 PST 2000 by gson */ @@ -45,7 +45,7 @@ fromtext_in_nsap_ptr(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); return (ISC_R_SUCCESS); } @@ -84,7 +84,7 @@ fromwire_in_nsap_ptr(ARGS_FROMWIRE) { dns_decompress_setmethods(dctx, DNS_COMPRESS_NONE); dns_name_init(&name, NULL); - return (dns_name_fromwire(&name, source, dctx, downcase, target)); + return (dns_name_fromwire(&name, source, dctx, options, target)); } static inline isc_result_t @@ -215,4 +215,31 @@ digest_in_nsap_ptr(ARGS_DIGEST) { return (dns_name_digest(&name, digest, arg)); } +static inline isc_boolean_t +checkowner_in_nsap_ptr(ARGS_CHECKOWNER) { + + REQUIRE(type == 23); + REQUIRE(rdclass == 1); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_in_nsap_ptr(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 23); + REQUIRE(rdata->rdclass == 1); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_IN_1_NSAP_PTR_23_C */ diff --git a/lib/dns/rdata/in_1/nsap_22.c b/lib/dns/rdata/in_1/nsap_22.c index 5dccd06849e..9284d75ae56 100644 --- a/lib/dns/rdata/in_1/nsap_22.c +++ b/lib/dns/rdata/in_1/nsap_22.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: nsap_22.c,v 1.36 2002/02/20 03:35:13 marka Exp $ */ +/* $Id: nsap_22.c,v 1.37 2004/02/27 20:41:50 marka Exp $ */ /* Reviewed: Fri Mar 17 10:41:07 PST 2000 by gson */ @@ -39,7 +39,7 @@ fromtext_in_nsap(ARGS_FROMTEXT) { UNUSED(type); UNUSED(origin); - UNUSED(downcase); + UNUSED(options); UNUSED(rdclass); UNUSED(callbacks); @@ -104,7 +104,7 @@ fromwire_in_nsap(ARGS_FROMWIRE) { UNUSED(type); UNUSED(dctx); - UNUSED(downcase); + UNUSED(options); UNUSED(rdclass); isc_buffer_activeregion(source, ®ion); @@ -225,4 +225,31 @@ digest_in_nsap(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_in_nsap(ARGS_CHECKOWNER) { + + REQUIRE(type == 22); + REQUIRE(rdclass == 1); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_in_nsap(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 22); + REQUIRE(rdata->rdclass == 1); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_IN_1_NSAP_22_C */ diff --git a/lib/dns/rdata/in_1/px_26.c b/lib/dns/rdata/in_1/px_26.c index f8d56a72e7d..781a5de93cb 100644 --- a/lib/dns/rdata/in_1/px_26.c +++ b/lib/dns/rdata/in_1/px_26.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: px_26.c,v 1.36 2003/07/25 00:01:10 marka Exp $ */ +/* $Id: px_26.c,v 1.37 2004/02/27 20:41:50 marka Exp $ */ /* Reviewed: Mon Mar 20 10:44:27 PST 2000 */ @@ -56,7 +56,7 @@ fromtext_in_px(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); /* * MAPX400. @@ -66,7 +66,7 @@ fromtext_in_px(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); return (ISC_R_SUCCESS); } @@ -140,12 +140,12 @@ fromwire_in_px(ARGS_FROMWIRE) { /* * MAP822. */ - RETERR(dns_name_fromwire(&name, source, dctx, downcase, target)); + RETERR(dns_name_fromwire(&name, source, dctx, options, target)); /* * MAPX400. */ - return (dns_name_fromwire(&name, source, dctx, downcase, target)); + return (dns_name_fromwire(&name, source, dctx, options, target)); } static inline isc_result_t @@ -344,4 +344,31 @@ digest_in_px(ARGS_DIGEST) { return (dns_name_digest(&name, digest, arg)); } +static inline isc_boolean_t +checkowner_in_px(ARGS_CHECKOWNER) { + + REQUIRE(type == 250); + REQUIRE(rdclass == 255); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_in_px(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 26); + REQUIRE(rdata->rdclass == 1); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_IN_1_PX_26_C */ diff --git a/lib/dns/rdata/in_1/srv_33.c b/lib/dns/rdata/in_1/srv_33.c index 81ef373ab1d..e19d3cda74a 100644 --- a/lib/dns/rdata/in_1/srv_33.c +++ b/lib/dns/rdata/in_1/srv_33.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: srv_33.c,v 1.38 2003/07/25 00:01:10 marka Exp $ */ +/* $Id: srv_33.c,v 1.39 2004/02/27 20:41:50 marka Exp $ */ /* Reviewed: Fri Mar 17 13:01:00 PST 2000 by bwelling */ @@ -31,6 +31,7 @@ fromtext_in_srv(ARGS_FROMTEXT) { isc_token_t token; dns_name_t name; isc_buffer_t buffer; + isc_boolean_t ok; REQUIRE(type == 33); REQUIRE(rdclass == 1); @@ -74,7 +75,14 @@ fromtext_in_srv(ARGS_FROMTEXT) { dns_name_init(&name, NULL); buffer_fromregion(&buffer, &token.value.as_region); origin = (origin != NULL) ? origin : dns_rootname; - RETTOK(dns_name_fromtext(&name, &buffer, origin, downcase, target)); + RETTOK(dns_name_fromtext(&name, &buffer, origin, options, target)); + ok = ISC_TRUE; + if ((options & DNS_RDATA_CHECKNAMES) != 0) + ok = dns_name_ishostname(&name, ISC_FALSE); + if (!ok && (options & DNS_RDATA_CHECKNAMESFAIL) != 0) + RETTOK(DNS_R_BADNAME); + if (!ok && callbacks != NULL) + warn_badname(&name, lexer, callbacks); return (ISC_R_SUCCESS); } @@ -157,7 +165,7 @@ fromwire_in_srv(ARGS_FROMWIRE) { /* * Target. */ - return (dns_name_fromwire(&name, source, dctx, downcase, target)); + return (dns_name_fromwire(&name, source, dctx, options, target)); } static inline isc_result_t @@ -326,4 +334,40 @@ digest_in_srv(ARGS_DIGEST) { return (dns_name_digest(&name, digest, arg)); } +static inline isc_boolean_t +checkowner_in_srv(ARGS_CHECKOWNER) { + + REQUIRE(type == 250); + REQUIRE(rdclass == 255); + + UNUSED(name); + UNUSED(type); + UNUSED(rdclass); + UNUSED(wildcard); + + return (ISC_TRUE); +} + +static inline isc_boolean_t +checknames_in_srv(ARGS_CHECKNAMES) { + isc_region_t region; + dns_name_t name; + + REQUIRE(rdata->type == 33); + REQUIRE(rdata->rdclass == 1); + + UNUSED(owner); + + dns_rdata_toregion(rdata, ®ion); + isc_region_consume(®ion, 6); + dns_name_init(&name, NULL); + dns_name_fromregion(&name, ®ion); + if (!dns_name_ishostname(&name, ISC_FALSE)) { + if (bad != NULL) + dns_name_clone(&name, bad); + return (ISC_FALSE); + } + return (ISC_TRUE); +} + #endif /* RDATA_IN_1_SRV_33_C */ diff --git a/lib/dns/rdata/in_1/wks_11.c b/lib/dns/rdata/in_1/wks_11.c index 82e6ffd3090..b281e1cf636 100644 --- a/lib/dns/rdata/in_1/wks_11.c +++ b/lib/dns/rdata/in_1/wks_11.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: wks_11.c,v 1.49 2002/02/20 03:35:14 marka Exp $ */ +/* $Id: wks_11.c,v 1.50 2004/02/27 20:41:50 marka Exp $ */ /* Reviewed: Fri Mar 17 15:01:49 PST 2000 by explorer */ @@ -52,7 +52,7 @@ fromtext_in_wks(ARGS_FROMTEXT) { UNUSED(type); UNUSED(origin); - UNUSED(downcase); + UNUSED(options); UNUSED(rdclass); /* @@ -181,7 +181,7 @@ fromwire_in_wks(ARGS_FROMWIRE) { UNUSED(type); UNUSED(dctx); - UNUSED(downcase); + UNUSED(options); UNUSED(rdclass); isc_buffer_activeregion(source, &sr); @@ -321,4 +321,29 @@ digest_in_wks(ARGS_DIGEST) { return ((digest)(arg, &r)); } +static inline isc_boolean_t +checkowner_in_wks(ARGS_CHECKOWNER) { + + REQUIRE(type == 11); + REQUIRE(rdclass == 1); + + UNUSED(type); + UNUSED(rdclass); + + return (dns_name_ishostname(name, wildcard)); +} + +static inline isc_boolean_t +checknames_in_wks(ARGS_CHECKNAMES) { + + REQUIRE(rdata->type == 11); + REQUIRE(rdata->rdclass == 1); + + UNUSED(rdata); + UNUSED(owner); + UNUSED(bad); + + return (ISC_TRUE); +} + #endif /* RDATA_IN_1_WKS_11_C */ diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 6184ec6cf8a..972fa960b1f 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: resolver.c,v 1.281 2004/02/20 00:52:45 marka Exp $ */ +/* $Id: resolver.c,v 1.282 2004/02/27 20:41:44 marka Exp $ */ #include @@ -2909,6 +2909,7 @@ clone_results(fetchctx_t *fctx) { #define EXTERNAL(r) (((r)->attributes & DNS_RDATASETATTR_EXTERNAL) != 0) #define CHAINING(r) (((r)->attributes & DNS_RDATASETATTR_CHAINING) != 0) #define CHASE(r) (((r)->attributes & DNS_RDATASETATTR_CHASE) != 0) +#define CHECKNAMES(r) (((r)->attributes & DNS_RDATASETATTR_CHECKNAMES) != 0) /* @@ -3236,6 +3237,7 @@ cache_name(fetchctx_t *fctx, dns_name_t *name, isc_stdtime_t now) { unsigned int options; isc_task_t *task; dns_validator_t *validator; + isc_boolean_t fail; /* * The appropriate bucket lock must be held. @@ -3305,11 +3307,33 @@ cache_name(fetchctx_t *fctx, dns_name_t *name, isc_stdtime_t now) { /* * Cache or validate each cacheable rdataset. */ + fail = (fctx->res->options & DNS_RESOLVER_CHECKNAMESFAIL) != 0; for (rdataset = ISC_LIST_HEAD(name->list); rdataset != NULL; rdataset = ISC_LIST_NEXT(rdataset, link)) { if (!CACHE(rdataset)) continue; + if (CHECKNAMES(rdataset)) { + char namebuf[DNS_NAME_FORMATSIZE]; + char typebuf[DNS_RDATATYPE_FORMATSIZE]; + char classbuf[DNS_RDATATYPE_FORMATSIZE]; + + dns_name_format(name, namebuf, sizeof(namebuf)); + dns_rdatatype_format(rdataset->type, typebuf, + sizeof(typebuf)); + dns_rdataclass_format(rdataset->rdclass, classbuf, + sizeof(classbuf)); + isc_log_write(dns_lctx, DNS_LOGCATEGORY_RESOLVER, + DNS_LOGMODULE_RESOLVER, ISC_LOG_NOTICE, + "check-names %s %s/%s/%s", + fail ? "failure" : "warning", + namebuf, typebuf, classbuf); + if (fail) { + if (ANSWER(rdataset)) + return (DNS_R_BADNAME); + continue; + } + } /* * Enforce the configure maximum cache TTL. @@ -4748,6 +4772,48 @@ resume_dslookup(isc_task_t *task, isc_event_t *event) { empty_bucket(res); } +static inline void +checknamessection(dns_message_t *message, dns_section_t section) { + isc_result_t result; + dns_name_t *name; + dns_rdata_t rdata = DNS_RDATA_INIT; + dns_rdataset_t *rdataset; + + for (result = dns_message_firstname(message, section); + result == ISC_R_SUCCESS; + result = dns_message_nextname(message, section)) + { + name = NULL; + dns_message_currentname(message, section, &name); + for (rdataset = ISC_LIST_HEAD(name->list); + rdataset != NULL; + rdataset = ISC_LIST_NEXT(rdataset, link)) { + for (result = dns_rdataset_first(rdataset); + result == ISC_R_SUCCESS; + result = dns_rdataset_next(rdataset)) { + dns_rdataset_current(rdataset, &rdata); + if (!dns_rdata_checkowner(name, rdata.rdclass, + rdata.type, + ISC_FALSE) || + !dns_rdata_checknames(&rdata, name, NULL)) + { + rdataset->attributes |= + DNS_RDATASETATTR_CHECKNAMES; + } + dns_rdata_reset(&rdata); + } + } + } +} + +static void +checknames(dns_message_t *message) { + + checknamessection(message, DNS_SECTION_ANSWER); + checknamessection(message, DNS_SECTION_AUTHORITY); + checknamessection(message, DNS_SECTION_ADDITIONAL); +} + static void resquery_response(isc_task_t *task, isc_event_t *event) { isc_result_t result = ISC_R_SUCCESS; @@ -5084,6 +5150,9 @@ resquery_response(isc_task_t *task, isc_event_t *event) { domainbuf, namebuf, typebuf, classbuf, addrbuf); } + if ((fctx->res->options | DNS_RESOLVER_CHECKNAMES) != 0) + checknames(message); + /* * Did we get any answers? */ diff --git a/lib/dns/result.c b/lib/dns/result.c index 28d54df9290..a84086f77ba 100644 --- a/lib/dns/result.c +++ b/lib/dns/result.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: result.c,v 1.111 2004/01/14 02:06:50 marka Exp $ */ +/* $Id: result.c,v 1.112 2004/02/27 20:41:44 marka Exp $ */ #include @@ -144,7 +144,9 @@ static const char *text[DNS_R_NRESULTS] = { "empty wild", /* 93 DNS_R_EMPTYWILD */ "bad bitmap", /* 94 DNS_R_BADBITMAP */ - "from wildcard" /* 95 DNS_R_FROMWILDCARD */ + "from wildcard", /* 95 DNS_R_FROMWILDCARD */ + "bad owner name (check-names)", /* 96 DNS_R_BADOWNERNAME */ + "bad name (check-names)" /* 97 DNS_R_BADNAME */ }; static const char *rcode_text[DNS_R_NRCODERESULTS] = { diff --git a/lib/dns/sdb.c b/lib/dns/sdb.c index af33c3de4b4..60c048cc18b 100644 --- a/lib/dns/sdb.c +++ b/lib/dns/sdb.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: sdb.c,v 1.42 2004/02/03 00:59:05 marka Exp $ */ +/* $Id: sdb.c,v 1.43 2004/02/27 20:41:44 marka Exp $ */ #include @@ -392,7 +392,7 @@ dns_sdb_putrr(dns_sdblookup_t *lookup, const char *type, dns_ttl_t ttl, result = dns_rdata_fromtext(NULL, lookup->sdb->common.rdclass, typeval, lex, - origin, ISC_FALSE, + origin, 0, mctx, &rb, &lookup->callbacks); if (result != ISC_R_NOSPACE) diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c index 1dea2707266..13cd92ad560 100644 --- a/lib/dns/xfrin.c +++ b/lib/dns/xfrin.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: xfrin.c,v 1.133 2003/04/17 05:40:45 marka Exp $ */ +/* $Id: xfrin.c,v 1.134 2004/02/27 20:41:45 marka Exp $ */ #include @@ -275,6 +275,8 @@ axfr_putdata(dns_xfrin_ctx_t *xfr, dns_diffop_t op, isc_result_t result; dns_difftuple_t *tuple = NULL; + + CHECK(dns_zone_checknames(xfr->zone, name, rdata)); CHECK(dns_difftuple_create(xfr->diff.mctx, op, name, ttl, rdata, &tuple)); dns_diff_append(&xfr->diff, &tuple); @@ -351,6 +353,8 @@ ixfr_putdata(dns_xfrin_ctx_t *xfr, dns_diffop_t op, isc_result_t result; dns_difftuple_t *tuple = NULL; + if (op == DNS_DIFFOP_ADD) + CHECK(dns_zone_checknames(xfr->zone, name, rdata)); CHECK(dns_difftuple_create(xfr->diff.mctx, op, name, ttl, rdata, &tuple)); dns_diff_append(&xfr->diff, &tuple); diff --git a/lib/dns/zone.c b/lib/dns/zone.c index ed8f613ae53..c071d6cfbad 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: zone.c,v 1.404 2004/01/07 05:27:17 marka Exp $ */ +/* $Id: zone.c,v 1.405 2004/02/27 20:41:45 marka Exp $ */ #include @@ -48,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -1104,6 +1105,10 @@ zone_gotreadhandle(isc_task_t *task, isc_event_t *event) { options |= DNS_MASTER_CHECKNS; if (DNS_ZONE_OPTION(load->zone, DNS_ZONEOPT_FATALNS)) options |= DNS_MASTER_FATALNS; + if (DNS_ZONE_OPTION(load->zone, DNS_ZONEOPT_CHECKNAMES)) + options |= DNS_MASTER_CHECKNAMES; + if (DNS_ZONE_OPTION(load->zone, DNS_ZONEOPT_CHECKNAMESFAIL)) + options |= DNS_MASTER_CHECKNAMESFAIL; result = dns_master_loadfileinc(load->zone->masterfile, dns_db_origin(load->db), dns_db_origin(load->db), @@ -1170,6 +1175,10 @@ zone_startload(dns_db_t *db, dns_zone_t *zone, isc_time_t loadtime) { options |= DNS_MASTER_FATALNS; if (zone->type == dns_zone_slave) options |= DNS_MASTER_SLAVE; + if (DNS_ZONE_OPTION(zone, DNS_ZONEOPT_CHECKNAMES)) + options |= DNS_MASTER_CHECKNAMES; + if (DNS_ZONE_OPTION(zone, DNS_ZONEOPT_CHECKNAMESFAIL)) + options |= DNS_MASTER_CHECKNAMESFAIL; if (zone->zmgr != NULL && zone->db != NULL && zone->task != NULL) { load = isc_mem_get(zone->mctx, sizeof(*load)); @@ -6694,3 +6703,48 @@ dns_zonemgr_getcount(dns_zonemgr_t *zmgr, int state) { return (count); } + +isc_result_t +dns_zone_checknames(dns_zone_t *zone, dns_name_t *name, dns_rdata_t *rdata) { + isc_boolean_t ok = ISC_TRUE; + isc_boolean_t fail = ISC_FALSE; + char namebuf[DNS_NAME_FORMATSIZE]; + char namebuf2[DNS_NAME_FORMATSIZE]; + char typebuf[DNS_RDATATYPE_FORMATSIZE]; + unsigned int level = ISC_LOG_WARNING; + dns_name_t bad; + + REQUIRE(DNS_ZONE_VALID(zone)); + + if (!DNS_ZONE_OPTION(zone, DNS_ZONEOPT_CHECKNAMES)) + return (ISC_R_SUCCESS); + + if (DNS_ZONE_OPTION(zone, DNS_ZONEOPT_CHECKNAMESFAIL)) { + level = ISC_LOG_ERROR; + fail = ISC_TRUE; + } + + ok = dns_rdata_checkowner(name, rdata->rdclass, rdata->type, ISC_TRUE); + if (!ok) { + dns_name_format(name, namebuf, sizeof(namebuf)); + dns_rdatatype_format(rdata->type, typebuf, sizeof(typebuf)); + dns_zone_log(zone, level, "%s/%s: %s", namebuf, typebuf, + dns_result_totext(DNS_R_BADOWNERNAME)); + if (fail) + return (DNS_R_BADOWNERNAME); + } + + dns_name_init(&bad, NULL); + ok = dns_rdata_checknames(rdata, name, &bad); + if (!ok) { + dns_name_format(name, namebuf, sizeof(namebuf)); + dns_name_format(&bad, namebuf2, sizeof(namebuf2)); + dns_rdatatype_format(rdata->type, typebuf, sizeof(typebuf)); + dns_zone_log(zone, level, "%s/%s: %s: %s ", namebuf, typebuf, + namebuf2, dns_result_totext(DNS_R_BADNAME)); + if (fail) + return (DNS_R_BADNAME); + } + + return (ISC_R_SUCCESS); +} diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c index 7f105cac5b7..f5caf218ec9 100644 --- a/lib/isccfg/namedconf.c +++ b/lib/isccfg/namedconf.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: namedconf.c,v 1.26 2004/02/17 03:40:23 marka Exp $ */ +/* $Id: namedconf.c,v 1.27 2004/02/27 20:41:51 marka Exp $ */ #include @@ -345,9 +345,22 @@ static cfg_type_t cfg_type_rrsetorderingelement = { * A global or view "check-names" option. Note that the zone * "check-names" option has a different syntax. */ + +static const char *checktype_enums[] = { "master", "slave", "response", NULL }; +static cfg_type_t cfg_type_checktype = { + "checktype", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, + &cfg_rep_string, &checktype_enums +}; + +static const char *checkmode_enums[] = { "fail", "warn", "ignore", NULL }; +static cfg_type_t cfg_type_checkmode = { + "checkmode", cfg_parse_enum, cfg_print_ustring, cfg_doc_enum, + &cfg_rep_string, &checkmode_enums +}; + static cfg_tuplefielddef_t checknames_fields[] = { - { "type", &cfg_type_ustring, 0 }, - { "mode", &cfg_type_ustring, 0 }, + { "type", &cfg_type_checktype, 0 }, + { "mode", &cfg_type_checkmode, 0 }, { NULL, NULL, 0 } }; static cfg_type_t cfg_type_checknames = { @@ -668,8 +681,7 @@ view_clauses[] = { { "max-cache-ttl", &cfg_type_uint32, 0 }, { "transfer-format", &cfg_type_transferformat, 0 }, { "max-cache-size", &cfg_type_sizenodefault, 0 }, - { "check-names", &cfg_type_checknames, - CFG_CLAUSEFLAG_MULTI | CFG_CLAUSEFLAG_NOTIMP }, + { "check-names", &cfg_type_checknames, CFG_CLAUSEFLAG_MULTI }, { "cache-file", &cfg_type_qstring, 0 }, { "suppress-initial-notify", &cfg_type_boolean, CFG_CLAUSEFLAG_NYI }, { "preferred-glue", &cfg_type_astring, 0 }, @@ -755,7 +767,7 @@ zone_only_clauses[] = { * Note that the format of the check-names option is different between * the zone options and the global/view options. Ugh. */ - { "check-names", &cfg_type_ustring, CFG_CLAUSEFLAG_NOTIMP }, + { "check-names", &cfg_type_checkmode, 0 }, { NULL, NULL, 0 } };