From db948cd6b533d58cbbd303741fd211ee41c32e49 Mon Sep 17 00:00:00 2001 From: Dirk Date: Wed, 26 Sep 2018 13:41:35 +0200 Subject: [PATCH] Make sure length bytes are two chars wide Linux bash internal printf shortened the string when using len2twobytes() with 3 chars, FreeBSD e.g. did not. It worked under both OS though when piping to the socket with printf. This commit makes sure that always 2+2 chars are returned when a 3 char number is supplied. Kudos @dcooper16 --- testssl.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testssl.sh b/testssl.sh index 5d3833f..39300aa 100755 --- a/testssl.sh +++ b/testssl.sh @@ -9158,7 +9158,7 @@ code2network() { len2twobytes() { local len_arg1=${#1} [[ $len_arg1 -le 2 ]] && LEN_STR=$(printf "00, %02s \n" "$1") - [[ $len_arg1 -eq 3 ]] && LEN_STR=$(printf "%02s, %02s \n" "${1:0:1}" "${1:1:2}") + [[ $len_arg1 -eq 3 ]] && LEN_STR=$(printf "0%s, %02s \n" "${1:0:1}" "${1:1:2}") [[ $len_arg1 -eq 4 ]] && LEN_STR=$(printf "%02s, %02s \n" "${1:0:2}" "${1:2:2}") }