Validate netmask in mem_pool_create

This commit is contained in:
Tobias Brunner
2012-08-13 13:54:28 +02:00
parent 305d98b780
commit 3a917ac77f
+1
View File
@@ -480,6 +480,7 @@ mem_pool_t *mem_pool_create(char *name, host_t *base, int bits)
if (base) if (base)
{ {
addr_bits = base->get_family(base) == AF_INET ? 32 : 128; addr_bits = base->get_family(base) == AF_INET ? 32 : 128;
bits = max(0, min(bits, base->get_family(base) == AF_INET ? 32 : 128));
/* net bits -> host bits */ /* net bits -> host bits */
bits = addr_bits - bits; bits = addr_bits - bits;
if (bits > POOL_LIMIT) if (bits > POOL_LIMIT)