mem-pool: Reject the creation of unintentionally empty pools

If a base address is configured, we don't expect the pool to be empty,
so reject the creation (e.g. with the broadcast address as base).

References strongswan/strongswan#2205
This commit is contained in:
Tobias Brunner
2024-04-15 09:50:41 +02:00
parent afeac365fd
commit 5f99a28381
3 changed files with 21 additions and 8 deletions
+2 -5
View File
@@ -153,13 +153,10 @@ START_TEST(test_cidr_offset)
pool->destroy(pool);
base->destroy(base);
/* due to size == 0 we get the requested IP back */
/* this results in an empty pool, which is rejected */
base = host_create_from_string("192.168.0.255", 0);
pool = mem_pool_create("test", base, 24);
ck_assert_int_eq(0, pool->get_size(pool));
assert_acquire(pool, "192.168.0.1", "192.168.0.1", MEM_POOL_NEW);
pool->destroy(pool);
ck_assert(!pool);
base->destroy(base);
}
END_TEST