]> git.ipfire.org Git - people/stevee/network.git/commitdiff
DHCP: Check if range is not negative
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 8 Sep 2016 16:40:23 +0000 (18:40 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 8 Sep 2016 16:40:23 +0000 (18:40 +0200)
If a new range is created, we now check if range is positive
(even for IPv6).

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.dhcpd

index 71afefc5f252d27d8ddc26ec5d0a17bfa6aea15e..b112eed62e0b5d10eb19e5dfcc12965a94aeda20 100644 (file)
@@ -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.