mirror of
https://github.com/drwetter/testssl.sh.git
synced 2024-12-31 22:09:44 +01:00
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
This commit is contained in:
parent
e1ee04fbd7
commit
db948cd6b5
@ -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}")
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user