From: Jonatan Schlag Date: Tue, 30 May 2017 08:54:43 +0000 (+0200) Subject: ip: Correctly handle non-numeric prefixes X-Git-Tag: 009~257 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0da7539dd7ac75b01c1869c0fcc885685e0faa90;p=network.git ip: Correctly handle non-numeric prefixes Signed-off-by: Jonatan Schlag Signed-off-by: Michael Tremer --- diff --git a/src/functions/functions.ipv4 b/src/functions/functions.ipv4 index 0f1455ca..96135888 100644 --- a/src/functions/functions.ipv4 +++ b/src/functions/functions.ipv4 @@ -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} diff --git a/src/functions/functions.ipv6 b/src/functions/functions.ipv6 index f2a5fadd..9f1b2a93 100644 --- a/src/functions/functions.ipv6 +++ b/src/functions/functions.ipv6 @@ -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}