summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorPatrick Grimm <patrick@lunatiki.de>2015-06-18 04:45:45 +0200
committerPatrick Grimm <patrick@lunatiki.de>2015-06-18 04:45:45 +0200
commitb55ea3757c37a3daf19547fc3c6f437221c79a0c (patch)
tree93b363597506531eac2d76559dc7466b8210f716 /src
parentd5b2b5353e99552ac68fef21a19fdb9157dcf96b (diff)
dhcpv4: fix unitialization of mask
Signed-off-by: Patrick Grimm <patrick@lunatiki.de>
Diffstat (limited to 'src')
-rw-r--r--src/dhcpv4.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c
index 07ad3ff..f6f4b0a 100644
--- a/src/dhcpv4.c
+++ b/src/dhcpv4.c
@@ -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