]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Radix tree node_num value could be set incorrectly, causing positive ACL
authorEvan Hunt <each@isc.org>
Tue, 27 Nov 2007 19:14:45 +0000 (19:14 +0000)
committerEvan Hunt <each@isc.org>
Tue, 27 Nov 2007 19:14:45 +0000 (19:14 +0000)
matches to look like negative ones.  [rt17311]

CHANGES
lib/isc/radix.c

diff --git a/CHANGES b/CHANGES
index c32cc413017e4c57e73777d4f1f0f2a3dc1efe70..3fb8f2cc914474220442ca4f8cf1b70f812105f4 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+2267.   [bug]           Radix tree node_num value could be set incorrectly,
+                        causing positive ACL matches to look like negative
+                        ones.  [RT #17311]
+
 2266.  [bug]           client.c:get_clientmctx() returned the same mctx
                        once the pool of mctx's was filled. [RT #17218]
 
index c7f75d7127d1fc18e463549386c44f557da1f672..f9a2c5075391e409852ce65e24ed7eea65d2f94a 100644 (file)
@@ -14,7 +14,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: radix.c,v 1.7 2007/09/28 00:11:32 each Exp $ */
+/* $Id: radix.c,v 1.8 2007/11/27 19:14:45 each Exp $ */
 
 /*
  * This source was adapted from MRT's RCS Ids:
@@ -115,6 +115,10 @@ _ref_prefix(isc_mem_t *mctx, isc_prefix_t **target, isc_prefix_t *prefix) {
 static int 
 _comp_with_mask(void *addr, void *dest, u_int mask) {
 
+        /* Mask length of zero matches everything */
+        if (mask == 0)
+                return (1);
+
        if (memcmp(addr, dest, mask / 8) == 0) {
                int n = mask / 8;
                int m = ((~0) << (8 - (mask % 8)));
@@ -297,7 +301,6 @@ isc_radix_insert(isc_radix_tree_t *radix, isc_radix_node_t **target,
                prefix = source->prefix;
 
        INSIST(prefix != NULL);
-
        if (radix->head == NULL) {
                node = isc_mem_get(radix->mctx, sizeof(isc_radix_node_t));
                if (node == NULL)
@@ -324,7 +327,6 @@ isc_radix_insert(isc_radix_tree_t *radix, isc_radix_node_t **target,
        node = radix->head;
 
        while (node->bit < bitlen || node->prefix == NULL) {
-
                if (node->bit < radix->maxbits &&
                    BIT_TEST(addr[node->bit >> 3], 0x80 >> (node->bit & 0x07)))
                {
@@ -379,7 +381,8 @@ isc_radix_insert(isc_radix_tree_t *radix, isc_radix_node_t **target,
                result = _ref_prefix(radix->mctx, &node->prefix, prefix);
                if (result != ISC_R_SUCCESS)
                        return (result);
-               INSIST(node->data == NULL);
+               INSIST(node->data == NULL && node->node_num == -1);
+               node->node_num = ++radix->num_added_node;
                *target = node;
                return (ISC_R_SUCCESS);
        }