Fixes floating point exeption (IPv6 only).
Signed-off-by: Matthias Fischer matthias.fischer@ipfire.org --- lfs/dnsmasq | 1 + ...-zero_when_dhcp-range_is_a_whole_slash_64.patch | 59 ++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 src/patches/dnsmasq/005-Avoid_divide-by-zero_when_dhcp-range_is_a_whole_slash_64.patch
diff --git a/lfs/dnsmasq b/lfs/dnsmasq index 67e6a61..6417a75 100644 --- a/lfs/dnsmasq +++ b/lfs/dnsmasq @@ -77,6 +77,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/002-Make_names_of_ARP_script_actions_consistent.patch cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/003-Fix_breakage_in_ARP_code_when_IPV6_support_not_compiled_in.patch cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/004-Avoid_losing_timer_when_deleting_a_RA_context.patch + cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/005-Avoid_divide-by-zero_when_dhcp-range_is_a_whole_slash_64.patch cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq-Add-support-to-read-ISC-DHCP-lease-file.patch
cd $(DIR_APP) && sed -i src/config.h \ diff --git a/src/patches/dnsmasq/005-Avoid_divide-by-zero_when_dhcp-range_is_a_whole_slash_64.patch b/src/patches/dnsmasq/005-Avoid_divide-by-zero_when_dhcp-range_is_a_whole_slash_64.patch new file mode 100644 index 0000000..acf1180 --- /dev/null +++ b/src/patches/dnsmasq/005-Avoid_divide-by-zero_when_dhcp-range_is_a_whole_slash_64.patch @@ -0,0 +1,59 @@ +From fdc97e13836ba83a6091b7eac79ba8ec40f1ddb9 Mon Sep 17 00:00:00 2001 +From: Simon Kelley simon@thekelleys.org.uk +Date: Sat, 13 Feb 2016 17:47:17 +0000 +Subject: [PATCH] Avoid divide-by-zero when dhcp-range is a whole /64 + +--- + CHANGELOG | 11 +++++++---- + src/dhcp6.c | 11 ++++++++++- + 2 files changed, 17 insertions(+), 5 deletions(-) + +diff --git a/CHANGELOG b/CHANGELOG +index 5feb47c..14354f2 100644 +--- a/CHANGELOG ++++ b/CHANGELOG +@@ -40,12 +40,15 @@ version 2.76 + + Extend --add-mac to allow a new encoding of the MAC address + as base64, by configurting --add-mac=base64 +- ++ + Add --add-cpe-id option. + +- +- +- ++ Don't crash with divide-by-zero if an IPv6 dhcp-range ++ is declared as a whole /64. ++ (ie xx::0 to xx::ffff:ffff:ffff:ffff) ++ Thanks to Laurent Bendel for spotting this problem. ++ ++ + version 2.75 + Fix reversion on 2.74 which caused 100% CPU use when a + dhcp-script is configured. Thanks to Adrian Davey for +diff --git a/src/dhcp6.c b/src/dhcp6.c +index 7269fd2..93a359e 100644 +--- a/src/dhcp6.c ++++ b/src/dhcp6.c +@@ -434,7 +434,16 @@ struct dhcp_context *address6_allocate(struct dhcp_context *context, unsigned c + /* seed is largest extant lease addr in this context */ + start = lease_find_max_addr6(c) + serial; + else +- start = addr6part(&c->start6) + ((j + c->addr_epoch) % (1 + addr6part(&c->end6) - addr6part(&c->start6))); ++ { ++ u64 range = 1 + addr6part(&c->end6) - addr6part(&c->start6); ++ u64 offset = j + c->addr_epoch; ++ ++ /* don't divide by zero if range is whole 2^64 */ ++ if (range != 0) ++ offset = offset % range; ++ ++ start = addr6part(&c->start6) + offset; ++ } + + /* iterate until we find a free address. */ + addr = start; +-- +1.7.10.4 +