Blame SOURCES/dnsmasq-2.81-correct-range-check-of-dhcp-host-prefix.patch

85f98a
From 6307208c806f9b968eca178931b3d77c4ed83c54 Mon Sep 17 00:00:00 2001
85f98a
From: Petr Mensik <pemensik@redhat.com>
85f98a
Date: Fri, 6 Mar 2020 15:37:23 +0100
85f98a
Subject: [PATCH] Correct range check of dhcp-host prefix
85f98a
85f98a
It incorrectly works with 32 bit integer only when counting number of
85f98a
addresses in range. It works correctly only between prefixlen 96 and
85f98a
128. Use 64bit shift to work with well with numbers higher than 64.
85f98a
85f98a
Fixes commit 79aba0f10ad0157fb4f48afbbcb03f094caff97a error.
85f98a
---
85f98a
 src/option.c  | 2 +-
85f98a
 src/rfc3315.c | 2 +-
85f98a
 2 files changed, 2 insertions(+), 2 deletions(-)
85f98a
85f98a
diff --git a/src/option.c b/src/option.c
85f98a
index 88cd2ab..79122df 100644
85f98a
--- a/src/option.c
85f98a
+++ b/src/option.c
85f98a
@@ -3247,7 +3247,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
85f98a
 			
85f98a
 			if (!atoi_check(pref, &new_addr->prefixlen) ||
85f98a
 			    new_addr->prefixlen > 128 ||
85f98a
-			    (((1<<(128-new_addr->prefixlen))-1) & addrpart) != 0)
85f98a
+			    ((((u64)1<<(128-new_addr->prefixlen))-1) & addrpart) != 0)
85f98a
 			  {
85f98a
 			    dhcp_config_free(new);
85f98a
 			    ret_err(_("bad IPv6 prefix"));
85f98a
diff --git a/src/rfc3315.c b/src/rfc3315.c
85f98a
index a0067e9..f59aedc 100644
85f98a
--- a/src/rfc3315.c
85f98a
+++ b/src/rfc3315.c
85f98a
@@ -1798,7 +1798,7 @@ static int config_valid(struct dhcp_config *config, struct dhcp_context *context
85f98a
       addresses = 1;
85f98a
 
85f98a
       if (addr_list->flags & ADDRLIST_PREFIX)
85f98a
-	addresses = 1<<(128-addr_list->prefixlen);
85f98a
+	addresses = (u64)1<<(128-addr_list->prefixlen);
85f98a
 		
85f98a
       if ((addr_list->flags & ADDRLIST_WILDCARD))
85f98a
 	{
85f98a
-- 
85f98a
2.21.1
85f98a