Commit 0899d16e authored by Evan Hunt's avatar Evan Hunt
Browse files

Radix tree node_num value could be set incorrectly, causing positive ACL

matches to look like negative ones.  [rt17311]
parent 4fe662ae
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 2266. [bug] client.c:get_clientmctx() returned the same mctx
once the pool of mctx's was filled. [RT #17218] once the pool of mctx's was filled. [RT #17218]
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
* PERFORMANCE OF THIS SOFTWARE. * 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: * 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) { ...@@ -115,6 +115,10 @@ _ref_prefix(isc_mem_t *mctx, isc_prefix_t **target, isc_prefix_t *prefix) {
static int static int
_comp_with_mask(void *addr, void *dest, u_int mask) { _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) { if (memcmp(addr, dest, mask / 8) == 0) {
int n = mask / 8; int n = mask / 8;
int m = ((~0) << (8 - (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, ...@@ -297,7 +301,6 @@ isc_radix_insert(isc_radix_tree_t *radix, isc_radix_node_t **target,
prefix = source->prefix; prefix = source->prefix;
INSIST(prefix != NULL); INSIST(prefix != NULL);
if (radix->head == NULL) { if (radix->head == NULL) {
node = isc_mem_get(radix->mctx, sizeof(isc_radix_node_t)); node = isc_mem_get(radix->mctx, sizeof(isc_radix_node_t));
if (node == NULL) if (node == NULL)
...@@ -324,7 +327,6 @@ isc_radix_insert(isc_radix_tree_t *radix, isc_radix_node_t **target, ...@@ -324,7 +327,6 @@ isc_radix_insert(isc_radix_tree_t *radix, isc_radix_node_t **target,
node = radix->head; node = radix->head;
while (node->bit < bitlen || node->prefix == NULL) { while (node->bit < bitlen || node->prefix == NULL) {
if (node->bit < radix->maxbits && if (node->bit < radix->maxbits &&
BIT_TEST(addr[node->bit >> 3], 0x80 >> (node->bit & 0x07))) 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, ...@@ -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); result = _ref_prefix(radix->mctx, &node->prefix, prefix);
if (result != ISC_R_SUCCESS) if (result != ISC_R_SUCCESS)
return (result); return (result);
INSIST(node->data == NULL); INSIST(node->data == NULL && node->node_num == -1);
node->node_num = ++radix->num_added_node;
*target = node; *target = node;
return (ISC_R_SUCCESS); return (ISC_R_SUCCESS);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment