From e66c74e0a72023921dfdd1de504a9fd8ddf1ddb7 Mon Sep 17 00:00:00 2001 From: Jonatan Schlag Date: Tue, 30 May 2017 10:54:43 +0200 Subject: [PATCH] ip: Correctly handle non-numeric prefixes Signed-off-by: Jonatan Schlag --- src/functions/functions.ipv4 | 3 ++- src/functions/functions.ipv6 | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) 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} -- 2.47.2