From: Michael Tremer Date: Thu, 8 Sep 2016 16:40:23 +0000 (+0200) Subject: DHCP: Check if range is not negative X-Git-Tag: 009~288 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7da6a387cccd40390e399b50a2a6837395bff02e;p=network.git DHCP: Check if range is not negative If a new range is created, we now check if range is positive (even for IPv6). Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.dhcpd b/src/functions/functions.dhcpd index 71afefc5..b112eed6 100644 --- a/src/functions/functions.dhcpd +++ b/src/functions/functions.dhcpd @@ -716,11 +716,9 @@ dhcpd_subnet_range_new() { local settings case "${proto}" in ipv6) - ip_encode="ipv6_encode" settings=${DHCPV6D_SUBNET_RANGE_SETTINGS} ;; ipv4) - ip_encode="ipv4_encode" settings=${DHCPV4D_SUBNET_RANGE_SETTINGS} ;; esac @@ -751,16 +749,10 @@ dhcpd_subnet_range_new() { fi done - # XXX currently, this check can only be performed for IPv4 - if [ "${proto}" = "ipv4" ]; then - # Check if the end address is greater than the start address. - local start_encoded=$(${ip_encode} ${START}) - local end_encoded=$(${ip_encode} ${END}) - - if [ ${start_encoded} -ge ${end_encoded} ]; then - error "The start address of the range must be greater than the end address." - return ${EXIT_ERROR} - fi + # Check if the end address is larger than the start address + if ! ${proto}_addr_gt "${END}" "${START}"; then + error "The end address of the range must be greater than the start address" + return ${EXIT_ERROR} fi # Write the configuration to file.