]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
1582. [bug] rrset-order failed to work on RRsets with more
authorMark Andrews <marka@isc.org>
Thu, 19 Feb 2004 01:23:42 +0000 (01:23 +0000)
committerMark Andrews <marka@isc.org>
Thu, 19 Feb 2004 01:23:42 +0000 (01:23 +0000)
                        than 32 elements. [RT #10381]

CHANGES
lib/dns/compress.c
lib/dns/rdataset.c

diff --git a/CHANGES b/CHANGES
index 8b24c74af298f5e7305bcffc772fa2dac9a33676..dbd61000a642d4831c0c45458e5aa75b634ededc 100644 (file)
--- 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.
index d4ce5a1499ebf700340bed5b4200f9ad3df3bffb..1535ce97c6905f006ea672865278c9a26f4a9fdb 100644 (file)
@@ -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;
index 59517dfc511ec6bf0934e8a51eacace2bacb1818..b57af152601235559102b075cb7a4b30db3eb3a3 100644 (file)
  * 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 <config.h>
 
 #include <stdlib.h>
 
 #include <isc/buffer.h>
+#include <isc/mem.h>
 #include <isc/random.h>
 #include <isc/util.h>
 
@@ -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);
 }