dhcpv4: fix unitialization of mask
authorPatrick Grimm <patrick@lunatiki.de>
Thu, 18 Jun 2015 02:45:45 +0000 (04:45 +0200)
committerPatrick Grimm <patrick@lunatiki.de>
Thu, 18 Jun 2015 02:45:45 +0000 (04:45 +0200)
Signed-off-by: Patrick Grimm <patrick@lunatiki.de>
src/dhcpv4.c

index 07ad3ffd78c352e940cb6ab1a4552772154e54cd..f6f4b0a94150f51431c9be6fb767fbb0732af486 100644 (file)
@@ -123,11 +123,12 @@ int setup_dhcpv4_interface(struct interface *iface, bool enable)
                inet_pton(AF_INET,saddr, &addr);
                int bits = ubus_get_mask4(iface->name);
                struct in_addr mask;
-               if (!(bits < -32 || bits > 32)) {
-                       mask.s_addr = bits ? htonl(~((1 << (32 - abs(bits))) - 1)) : 0;
-                       if (bits < 0)
-                               mask.s_addr = ~mask.s_addr;
-               }
+               if (bits < -32 || bits > 32)
+                       bits = 0;
+
+               mask.s_addr = bits ? htonl(~((1 << (32 - abs(bits))) - 1)) : 0;
+               if (bits < 0)
+                       mask.s_addr = ~mask.s_addr;
 
 
                // Create a range if not specified