mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
Avoid divide-by-zero when dhcp-range is a whole /64
This commit is contained in:
11
CHANGELOG
11
CHANGELOG
@@ -40,12 +40,15 @@ version 2.76
|
|||||||
|
|
||||||
Extend --add-mac to allow a new encoding of the MAC address
|
Extend --add-mac to allow a new encoding of the MAC address
|
||||||
as base64, by configurting --add-mac=base64
|
as base64, by configurting --add-mac=base64
|
||||||
|
|
||||||
Add --add-cpe-id option.
|
Add --add-cpe-id option.
|
||||||
|
|
||||||
|
Don't crash with divide-by-zero if an IPv6 dhcp-range
|
||||||
|
is declared as a whole /64.
|
||||||
|
(ie xx::0 to xx::ffff:ffff:ffff:ffff)
|
||||||
|
Thanks to Laurent Bendel for spotting this problem.
|
||||||
|
|
||||||
|
|
||||||
version 2.75
|
version 2.75
|
||||||
Fix reversion on 2.74 which caused 100% CPU use when a
|
Fix reversion on 2.74 which caused 100% CPU use when a
|
||||||
dhcp-script is configured. Thanks to Adrian Davey for
|
dhcp-script is configured. Thanks to Adrian Davey for
|
||||||
|
|||||||
11
src/dhcp6.c
11
src/dhcp6.c
@@ -434,7 +434,16 @@ struct dhcp_context *address6_allocate(struct dhcp_context *context, unsigned c
|
|||||||
/* seed is largest extant lease addr in this context */
|
/* seed is largest extant lease addr in this context */
|
||||||
start = lease_find_max_addr6(c) + serial;
|
start = lease_find_max_addr6(c) + serial;
|
||||||
else
|
else
|
||||||
start = addr6part(&c->start6) + ((j + c->addr_epoch) % (1 + addr6part(&c->end6) - addr6part(&c->start6)));
|
{
|
||||||
|
u64 range = 1 + addr6part(&c->end6) - addr6part(&c->start6);
|
||||||
|
u64 offset = j + c->addr_epoch;
|
||||||
|
|
||||||
|
/* don't divide by zero if range is whole 2^64 */
|
||||||
|
if (range != 0)
|
||||||
|
offset = offset % range;
|
||||||
|
|
||||||
|
start = addr6part(&c->start6) + offset;
|
||||||
|
}
|
||||||
|
|
||||||
/* iterate until we find a free address. */
|
/* iterate until we find a free address. */
|
||||||
addr = start;
|
addr = start;
|
||||||
|
|||||||
Reference in New Issue
Block a user