diff options
-rwxr-xr-x | debvm-waitssh | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/debvm-waitssh b/debvm-waitssh index bde1a93..a35c783 100755 --- a/debvm-waitssh +++ b/debvm-waitssh @@ -142,6 +142,19 @@ case "$1" in ;; esac +# Guard against strings containing anything but digits, strings starting with +# zero and empty strings as the port number. +# +# We cannot use [!0-9] because that matches on any character (or possibly +# multi-character collation element) that sorts in between 0 and 9. +case "$PORT" in *[!0123456789]*|0?*|""|??????*) + if [ "$VERBOSITY" -ge 1 ]; then + echo "$0: port '$PORT' is not a positive integer between 1 and 99999" >&2 + fi + exit 1 + ;; +esac + now=$(date +%s) deadline=$((now + TOTALTIMEOUT)) while test "$now" -lt "$deadline"; do |