]> git.ipfire.org Git - people/stevee/network.git/commitdiff
ip: Correctly handle non-numeric prefixes
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Tue, 30 May 2017 08:54:43 +0000 (10:54 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 30 May 2017 14:53:26 +0000 (15:53 +0100)
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.ipv4
src/functions/functions.ipv6

index 0f1455cae78076943dff030370659cdd2398fa31..961358882b0478102c7c6f0f105b7593639a33bd 100644 (file)
@@ -28,7 +28,8 @@ ipv4_is_valid() {
 ipv4_prefix_is_valid() {
        local prefix=${1}
 
-       isset prefix || return ${EXIT_FALSE}
+       # Check if prefix is a number
+       isinteger prefix || return ${EXIT_FALSE}
 
        [ ${prefix} -le  0 ] && return ${EXIT_FALSE}
        [ ${prefix} -gt 32 ] && return ${EXIT_FALSE}
index f2a5fadd36b7a90da49aeb87fa0290e83a222716..9f1b2a939bf50ea69fa5985adbf8d61e212d2af3 100644 (file)
@@ -119,7 +119,9 @@ ipv6_net_is_valid() {
 
 ipv6_prefix_is_valid() {
        local prefix=${1}
-       assert isset prefix
+
+       # Check if prefix is a number
+       isinteger prefix || return ${EXIT_FALSE}
 
        [ ${prefix} -le   0 ] && return ${EXIT_FALSE}
        [ ${prefix} -gt 128 ] && return ${EXIT_FALSE}