diff options
author | Johannes Schauer Marin Rodrigues <josch@mister-muffin.de> | 2023-01-08 10:36:00 +0100 |
---|---|---|
committer | Johannes Schauer Marin Rodrigues <josch@mister-muffin.de> | 2023-01-08 20:41:28 +0100 |
commit | 8c488b7655b924066930b57b4a0d2ff8be4296b6 (patch) | |
tree | 143eaa8022879b4752a8112f86c1951da4e47fe0 | |
parent | f8e1cadb4ef1d63b1b7252d84b9e7234f55b2f6e (diff) | |
download | debvm-8c488b7655b924066930b57b4a0d2ff8be4296b6.tar.gz |
debvm-waitssh: error out if port number is not a positive integer
-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 |