diff --git a/CHANGES b/CHANGES index 8b24c74af2..dbd61000a6 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,5 @@ -1582. [placeholder] rt10381 +1582. [bug] rrset-order failed to work on RRsets with more + than 32 elements. [RT #10381] 1581. [func] Disable DNSSEC support by default. To enable DNSSEC specify "enable-dnssec yes;" in named.conf. diff --git a/lib/dns/compress.c b/lib/dns/compress.c index d4ce5a1499..1535ce97c6 100644 --- a/lib/dns/compress.c +++ b/lib/dns/compress.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: compress.c,v 1.50 2001/06/04 19:32:59 tale Exp $ */ +/* $Id: compress.c,v 1.51 2004/02/19 01:23:42 marka Exp $ */ #define DNS_NAME_USEINLINE 1 @@ -45,7 +45,7 @@ dns_compress_init(dns_compress_t *cctx, int edns, isc_mem_t *mctx) { unsigned int i; REQUIRE(cctx != NULL); - REQUIRE(mctx != NULL); + REQUIRE(mctx != NULL); /* See: rdataset.c:towiresorted(). */ cctx->allowed = 0; cctx->edns = edns; diff --git a/lib/dns/rdataset.c b/lib/dns/rdataset.c index 59517dfc51..b57af15260 100644 --- a/lib/dns/rdataset.c +++ b/lib/dns/rdataset.c @@ -15,13 +15,14 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rdataset.c,v 1.70 2004/01/14 02:06:50 marka Exp $ */ +/* $Id: rdataset.c,v 1.71 2004/02/19 01:23:42 marka Exp $ */ #include #include #include +#include #include #include @@ -293,8 +294,8 @@ towiresorted(dns_rdataset_t *rdataset, dns_name_t *owner_name, unsigned int headlen; isc_boolean_t question = ISC_FALSE; isc_boolean_t shuffle = ISC_FALSE; - dns_rdata_t shuffled[MAX_SHUFFLE]; - struct towire_sort sorted[MAX_SHUFFLE]; + dns_rdata_t *shuffled = NULL, shuffled_fixed[MAX_SHUFFLE]; + struct towire_sort *sorted = NULL, sorted_fixed[MAX_SHUFFLE]; UNUSED(state); @@ -306,6 +307,7 @@ towiresorted(dns_rdataset_t *rdataset, dns_name_t *owner_name, REQUIRE(DNS_RDATASET_VALID(rdataset)); REQUIRE(countp != NULL); REQUIRE((order == NULL) == (order_arg == NULL)); + REQUIRE(cctx != NULL && cctx->mctx != NULL); count = 0; if ((rdataset->attributes & DNS_RDATASETATTR_QUESTION) != 0) { @@ -332,18 +334,24 @@ towiresorted(dns_rdataset_t *rdataset, dns_name_t *owner_name, } /* - * We'll only shuffle if we've got enough slots in our - * deck. - * - * There's no point to shuffling SIGs. + * Do we want to shuffle this anwer? */ - if (!question && - count > 1 && + if (!question && count > 1 && (!WANT_FIXED(rdataset) || order != NULL) && - count <= MAX_SHUFFLE && rdataset->type != dns_rdatatype_rrsig) - { shuffle = ISC_TRUE; + + if (shuffle && count > MAX_SHUFFLE) { + shuffled = isc_mem_get(cctx->mctx, count * sizeof(*shuffled)); + sorted = isc_mem_get(cctx->mctx, count * sizeof(*sorted)); + if (shuffled == NULL || sorted == NULL) + shuffle = ISC_FALSE; + } else { + shuffled = shuffled_fixed; + sorted = sorted_fixed; + } + + if (shuffle) { /* * First we get handles to all of the rdata. */ @@ -356,7 +364,7 @@ towiresorted(dns_rdataset_t *rdataset, dns_name_t *owner_name, result = dns_rdataset_next(rdataset); } while (result == ISC_R_SUCCESS); if (result != ISC_R_NOMORE) - return (result); + goto cleanup; INSIST(i == count); /* @@ -494,7 +502,8 @@ towiresorted(dns_rdataset_t *rdataset, dns_name_t *owner_name, *countp += count; - return (ISC_R_SUCCESS); + result = ISC_R_SUCCESS; + goto cleanup; rollback: if (partial && result == ISC_R_NOSPACE) { @@ -502,13 +511,18 @@ towiresorted(dns_rdataset_t *rdataset, dns_name_t *owner_name, dns_compress_rollback(cctx, (isc_uint16_t)rrbuffer.used); *countp += added; *target = rrbuffer; - return (result); + goto cleanup; } INSIST(savedbuffer.used < 65536); dns_compress_rollback(cctx, (isc_uint16_t)savedbuffer.used); *countp = 0; *target = savedbuffer; + cleanup: + if (sorted != NULL && sorted != sorted_fixed) + isc_mem_put(cctx->mctx, sorted, count * sizeof(*sorted)); + if (shuffled != NULL && shuffled != shuffled_fixed) + isc_mem_put(cctx->mctx, shuffled, count * sizeof(*shuffled)); return (result); }