From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH] wireless-networks: validate priority Date: Thu, 24 Aug 2017 11:46:36 +0200 Message-ID: <1503567996-3839-1-git-send-email-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============4087245373858787715==" List-Id: --===============4087245373858787715== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Fixes: #11469 Signed-off-by: Jonatan Schlag --- src/functions/functions.wireless-networks | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/functions/functions.wireless-networks b/src/functions/functi= ons.wireless-networks index c1cf06a..8d2a32d 100644 --- a/src/functions/functions.wireless-networks +++ b/src/functions/functions.wireless-networks @@ -315,6 +315,18 @@ wireless_network_pre_shared_key() { fi } =20 +wireless_networks_priority_is_valid() { + assert [ $# -eq 1 ] + + local priority=3D${1} + + if ! isinteger priority || [ ! ${priority} -ge 0 ] || [ ! ${priority} -le 9= 99 ]; then + return ${EXIT_FALSE} + fi + + return ${EXIT_TRUE} +} + wireless_network_priority() { if [ ! $# -eq 2 ]; then log ERROR "Not enough arguments" @@ -324,8 +336,8 @@ wireless_network_priority() { local handle=3D"${1}" local priority=3D${2} =20 - 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 t= hen 1000" return ${EXIT_ERROR} fi =20 --=20 2.6.3 --===============4087245373858787715==--