From d881d39f3d6fc39d54a762a75cb30efd7f4d8d0b Mon Sep 17 00:00:00 2001 From: Guy Halse Date: Fri, 28 May 2021 15:04:54 +0200 Subject: [PATCH] Validate realm supplied as input --- tools/naptr-eduroam.sh | 7 ++++++- tools/radsec-dynsrv.sh | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/naptr-eduroam.sh b/tools/naptr-eduroam.sh index 1d45c4d..e5d2da8 100755 --- a/tools/naptr-eduroam.sh +++ b/tools/naptr-eduroam.sh @@ -14,7 +14,6 @@ usage() { test -n "${1}" || usage -REALM="${1}" DIGCMD=$(command -v dig) HOSTCMD=$(command -v host) PRINTCMD=$(command -v printf) @@ -69,6 +68,12 @@ host_it_naptr() { done } +REALM=$(validate_host ${1}) +if [ -z "${REALM}" ]; then + echo "Error: realm \"${1}\" failed validation" + usage +fi + if [ -x "${DIGCMD}" ]; then SERVERS=$(dig_it_naptr) elif [ -x "${HOSTCMD}" ]; then diff --git a/tools/radsec-dynsrv.sh b/tools/radsec-dynsrv.sh index 9ea182c..a1bbed3 100755 --- a/tools/radsec-dynsrv.sh +++ b/tools/radsec-dynsrv.sh @@ -14,7 +14,6 @@ usage() { test -n "${1}" || usage -REALM="${1}" DIGCMD=$(command -v digaaa) HOSTCMD=$(command -v host) PRINTCMD=$(command -v printf) @@ -47,6 +46,12 @@ host_it() { done } +REALM=$(validate_host ${1}) +if test -z "${REALM}" ; then + echo "Error: realm \"${1}\" failed validation" + usage +fi + if test -x "${DIGCMD}" ; then SERVERS=$(dig_it) elif test -x "${HOSTCMD}" ; then