aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSUZUKI, Shinsuke <suz@kame.net>2006-10-04 13:10:23 +0000
committerSUZUKI, Shinsuke <suz@kame.net>2006-10-04 13:10:23 +0000
commitbf8ef0cd5da4270db70c46e8bcbbe29bcc38b44f (patch)
tree533009c91e25280b44bd418e836e4fcb0f16597f
parenta5d04c580d7f4a2fb5adf3bf04751dcc80f17be0 (diff)
fixed a improper memory access when there is no free address in an
address pool. (Bug-ID 1563232) fixed a bug that a pooled address will never be reused even when it is released.
-rw-r--r--CHANGES7
-rw-r--r--config.c44
-rw-r--r--config.h1
3 files changed, 21 insertions, 31 deletions
diff --git a/CHANGES b/CHANGES
index 2895b80..18353b7 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,10 @@
+2006-10-04 SUZUKI, Shinsuke <suz@kame.net>
+ * config.c: fixed a improper memory access when there is no free
+ address in an address pool. (Bug-ID 1563232)
+
+ fixed a bug that a pooled address will never be reused even when
+ it is released.
+
2006-10-03 SUZUKI, Shinsuke <suz@kame.net>
* config.c: dhcp6s does not include a 0 refresh-time option in
ADVERTISE/REPLY message, when "option refreshtime" configuration does
diff --git a/config.c b/config.c
index e397d32..9a4cad7 100644
--- a/config.c
+++ b/config.c
@@ -2123,7 +2123,7 @@ create_pool(name, range)
dprintf(LOG_ERR, FNAME, "memory allocation failed");
return (NULL);
}
- pool->cur = pool->min = range->min;
+ pool->min = range->min;
pool->max = range->max;
return (pool);
@@ -2157,46 +2157,30 @@ get_free_address_from_pool(pool, addr)
struct pool_conf *pool;
struct in6_addr *addr;
{
- int found = 0;
- int round = 0;
- struct in6_addr first;
-
+ struct in6_addr cur;
if (!pool || !addr)
return (0);
dprintf(LOG_DEBUG, FNAME, "called (pool=%s)", pool->name);
- memcpy(&first, &pool->cur, sizeof(first));
-
- while (!found) {
- if (!is_leased(&pool->cur) &&
- !IN6_IS_ADDR_MULTICAST(&pool->cur) &&
- !IN6_IS_ADDR_LINKLOCAL(&pool->cur) &&
- !IN6_IS_ADDR_SITELOCAL(&pool->cur)) {
- memcpy(addr, &pool->cur, sizeof(*addr));
- found = 1;
+ for (cur = pool->min; in6_addr_cmp(&cur, &pool->max) <= 0;
+ in6_addr_inc(&cur)) {
+ if (!is_leased(&cur) &&
+ !IN6_IS_ADDR_MULTICAST(&cur) &&
+ !IN6_IS_ADDR_LINKLOCAL(&cur) &&
+ !IN6_IS_ADDR_SITELOCAL(&cur)) {
dprintf(LOG_DEBUG, FNAME, "found %s",
- in6addr2str(addr, 0));
- }
-
- if (in6_addr_cmp(&pool->cur, &pool->max) == 0) {
- memcpy(&pool->next, &pool->min, sizeof(pool->next));
- round = 1;
- } else {
- in6_addr_inc(&pool->cur);
+ in6addr2str(&cur, 0));
+ *addr= cur;
+ return 1;
}
dprintf(LOG_DEBUG, FNAME, "next address %s",
- in6addr2str(&pool->cur, 0));
-
- if (round && !found &&
- in6_addr_cmp(&pool->cur, &first) == 0) {
- dprintf(LOG_NOTICE, FNAME, "no available address");
- break;
- }
+ in6addr2str(&cur, 0));
}
- return (found);
+ dprintf(LOG_NOTICE, FNAME, "no available address");
+ return 0;
}
int
diff --git a/config.h b/config.h
index c63679f..c6db6d1 100644
--- a/config.h
+++ b/config.h
@@ -51,7 +51,6 @@ struct pool_conf {
struct in6_addr min;
struct in6_addr max;
- struct in6_addr cur;
};
/* per-interface information */