summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2017-07-03 16:39:21 +0200
committerHans Dedecker <dedeckeh@gmail.com>2017-09-13 15:32:07 +0200
commita827fcad451996f1a7043b479d8c6162174b2038 (patch)
treeefe79b7edb75c9e9b6b33d5da1125ca7d300c9ae
parentbea088b6afe84d06552880778dc791cad97d4aec (diff)
dhcpv4: avoid segfault when there's no IPv4 prefix
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
-rw-r--r--src/dhcpv4.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c
index c7ac058..b0a4603 100644
--- a/src/dhcpv4.c
+++ b/src/dhcpv4.c
@@ -95,7 +95,8 @@ int setup_dhcpv4_interface(struct interface *iface, bool enable)
return -1;
}
- uint32_t mask = iface->addr4[0].prefix ? htonl(~((1 << (32 - iface->addr4[0].prefix)) - 1)) : 0;
+ uint32_t mask = iface->addr4 && iface->addr4[0].prefix ?
+ htonl(~((1 << (32 - iface->addr4[0].prefix)) - 1)) : 0xffffffff;
/* Create a range if not specified */
if (!(iface->dhcpv4_start.s_addr & htonl(0xffff0000)) &&