diff options
Diffstat (limited to 'usr.sbin/bind/lib/dns/message.c')
-rw-r--r-- | usr.sbin/bind/lib/dns/message.c | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/usr.sbin/bind/lib/dns/message.c b/usr.sbin/bind/lib/dns/message.c index 5dbaa35c31a..8268f2bb7e7 100644 --- a/usr.sbin/bind/lib/dns/message.c +++ b/usr.sbin/bind/lib/dns/message.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2004, 2005 Internet Systems Consortium, Inc. ("ISC") + * Copyright (C) 2004-2006 Internet Systems Consortium, Inc. ("ISC") * Copyright (C) 1999-2003 Internet Software Consortium. * * Permission to use, copy, modify, and distribute this software for any @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $ISC: message.c,v 1.194.2.10.2.20 2005/06/07 01:42:23 marka Exp $ */ +/* $ISC: message.c,v 1.194.2.10.2.24 2006/02/28 06:32:54 marka Exp $ */ /*** *** Imports @@ -801,11 +801,37 @@ findname(dns_name_t **foundname, dns_name_t *target, } isc_result_t +dns_message_find(dns_name_t *name, dns_rdataclass_t rdclass, + dns_rdatatype_t type, dns_rdatatype_t covers, + dns_rdataset_t **rdataset) +{ + dns_rdataset_t *curr; + + if (rdataset != NULL) { + REQUIRE(*rdataset == NULL); + } + + for (curr = ISC_LIST_TAIL(name->list); + curr != NULL; + curr = ISC_LIST_PREV(curr, link)) { + if (curr->rdclass == rdclass && + curr->type == type && curr->covers == covers) { + if (rdataset != NULL) + *rdataset = curr; + return (ISC_R_SUCCESS); + } + } + + return (ISC_R_NOTFOUND); +} + +isc_result_t dns_message_findtype(dns_name_t *name, dns_rdatatype_t type, dns_rdatatype_t covers, dns_rdataset_t **rdataset) { dns_rdataset_t *curr; + REQUIRE(name != NULL); if (rdataset != NULL) { REQUIRE(*rdataset == NULL); } @@ -1030,7 +1056,7 @@ getquestions(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx, /* * Can't ask the same question twice. */ - result = dns_message_findtype(name, rdtype, 0, NULL); + result = dns_message_find(name, rdclass, rdtype, 0, NULL); if (result == ISC_R_SUCCESS) DO_FORMERR; @@ -1190,6 +1216,7 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx, && rdtype != dns_rdatatype_dnskey /* in a TKEY query */ && rdtype != dns_rdatatype_sig /* SIG(0) */ && rdtype != dns_rdatatype_tkey /* Win2000 TKEY */ + && msg->rdclass != dns_rdataclass_any && msg->rdclass != rdclass) DO_FORMERR; @@ -1279,12 +1306,9 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx, rdata->type = rdtype; rdata->flags = DNS_RDATA_UPDATE; result = ISC_R_SUCCESS; - } else if (rdtype == dns_rdatatype_tsig) + } else result = getrdata(source, msg, dctx, rdclass, rdtype, rdatalen, rdata); - else - result = getrdata(source, msg, dctx, msg->rdclass, - rdtype, rdatalen, rdata); if (result != ISC_R_SUCCESS) goto cleanup; rdata->rdclass = rdclass; @@ -1360,8 +1384,8 @@ getsection(isc_buffer_t *source, dns_message_t *msg, dns_decompress_t *dctx, DO_FORMERR; rdataset = NULL; - result = dns_message_findtype(name, rdtype, covers, - &rdataset); + result = dns_message_find(name, rdclass, rdtype, + covers, &rdataset); } /* @@ -1799,7 +1823,7 @@ dns_message_rendersection(dns_message_t *msg, dns_section_t sectionid, if (rdataset != NULL && (rdataset->attributes & DNS_RDATASETATTR_REQUIREDGLUE) != 0 && (rdataset->attributes & DNS_RDATASETATTR_RENDERED) == 0) { - void *order_arg = msg->order_arg; + const void *order_arg = msg->order_arg; st = *(msg->buffer); count = 0; if (partial) @@ -3187,7 +3211,7 @@ dns_message_getrawmessage(dns_message_t *msg) { void dns_message_setsortorder(dns_message_t *msg, dns_rdatasetorderfunc_t order, - void *order_arg) + const void *order_arg) { REQUIRE(DNS_MESSAGE_VALID(msg)); msg->order = order; |