dhcpv4: do not allow pool end address to overlap with broadcast address
authorDainis Jonitis <dainis.jonitis@ubnt.com>
Mon, 26 Nov 2018 12:53:51 +0000 (14:53 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Fri, 3 May 2019 12:51:52 +0000 (14:51 +0200)
Signed-off-by: Dainis Jonitis <dainis.jonitis@ubnt.com>
src/dhcpv4.c

index 679b7931d2e35e0ceb35c3ece50f1f05ed59dc79..b25046d4ab4f6e5771208059a2281eb2f5883c51 100644 (file)
@@ -239,7 +239,8 @@ static int setup_dhcpv4_addresses(struct interface *iface)
 
                odhcpd_bitlen2netmask(false, iface->addr4[i].prefix, &mask);
                if ((start & ntohl(~mask.s_addr)) == start &&
-                           (end & ntohl(~mask.s_addr)) == end) {
+                               (end & ntohl(~mask.s_addr)) == end &&
+                               end < ntohl(~mask.s_addr)) {    /* Exclude broadcast address */
                        iface->dhcpv4_start_ip.s_addr = htonl(start) |
                                                        (addr->s_addr & mask.s_addr);
                        iface->dhcpv4_end_ip.s_addr = htonl(end) |