mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 18:28:25 +00:00
Fix error in IPv6 prefix calculation.
Error with prefixed address assignment. When it is calculating number of addresses from prefixlen, it rotates only 32bit int instead of 64b uint. Only result is assigned to 64b variable. Two examples: dhcp-host=[2000::1230:0:0/92],correct-prefix dhcp-host=[2000::1234:5678:0/92],incorrect-prefix If prefix length is lower than 96, the result is zero. It means incorrect-prefix is not refused as it should. Fix is simple, attaching patch with it. Just rotate 64b int.
This commit is contained in:
committed by
Simon Kelley
parent
dded78b233
commit
46bdfe691a
@@ -3322,7 +3322,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
|
|
||||||
if (!atoi_check(pref, &new_addr->prefixlen) ||
|
if (!atoi_check(pref, &new_addr->prefixlen) ||
|
||||||
new_addr->prefixlen > 128 ||
|
new_addr->prefixlen > 128 ||
|
||||||
(((1<<(128-new_addr->prefixlen))-1) & addrpart) != 0)
|
((((u64)1<<(128-new_addr->prefixlen))-1) & addrpart) != 0)
|
||||||
{
|
{
|
||||||
dhcp_config_free(new);
|
dhcp_config_free(new);
|
||||||
ret_err(_("bad IPv6 prefix"));
|
ret_err(_("bad IPv6 prefix"));
|
||||||
|
|||||||
@@ -1731,7 +1731,7 @@ static int config_valid(struct dhcp_config *config, struct dhcp_context *context
|
|||||||
addresses = 1;
|
addresses = 1;
|
||||||
|
|
||||||
if (addr_list->flags & ADDRLIST_PREFIX)
|
if (addr_list->flags & ADDRLIST_PREFIX)
|
||||||
addresses = 1<<(128-addr_list->prefixlen);
|
addresses = (u64)1<<(128-addr_list->prefixlen);
|
||||||
|
|
||||||
if ((addr_list->flags & ADDRLIST_WILDCARD))
|
if ((addr_list->flags & ADDRLIST_WILDCARD))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user