]> git.ipfire.org Git - people/jschlag/network.git/commitdiff
wireless-networks: validate priority
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Thu, 24 Aug 2017 09:46:36 +0000 (11:46 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 24 Aug 2017 10:31:33 +0000 (12:31 +0200)
Fixes: #11469
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.wireless-networks

index feca20d695b961917f2e1d6286452e0d41a3ec60..4fedcb9d5eae31837274c8ac4fe1812b2e6e1e62 100644 (file)
@@ -393,6 +393,18 @@ wireless_network_pre_shared_key() {
        fi
 }
 
+wireless_networks_priority_is_valid() {
+       assert [ $# -eq 1 ]
+
+       local priority=${1}
+
+       if ! isinteger priority || [ ! ${priority} -ge 0 ] || [ ! ${priority} -le 999 ]; then
+               return ${EXIT_FALSE}
+       fi
+
+       return ${EXIT_TRUE}
+}
+
 wireless_network_priority() {
        if [ ! $# -eq 2 ]; then
                log ERROR "Not enough arguments"
@@ -402,8 +414,8 @@ wireless_network_priority() {
        local handle="${1}"
        local priority=${2}
 
-       if ! isinteger priority && [ ! ${priority} -ge 0 ]; then
-               log ERROR "The priority must be an integer greater or eqal zero"
+       if ! wireless_networks_priority_is_valid ${priority}; then
+               error "The priority must be an integer greater or eqal zero and and less then 1000"
                return ${EXIT_ERROR}
        fi