Skip to content

Commit 5e1db5f

Browse files
committed
Address CA file parsing problem (3.2)
.... by forbidding spaces in supplied CA files/directories Also now we're sanitizing the cmd line parameter better using `safe_echo()` See also #2647 .
1 parent 21a89e4 commit 5e1db5f

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

testssl.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23545,10 +23545,10 @@ set_skip_tests() {
2354523545
# arg2: value (if no = provided)
2354623546
parse_opt_equal_sign() {
2354723547
if [[ "$1" == *=* ]]; then
23548-
echo ${1#*=}
23548+
safe_echo "${1#*=}"
2354923549
return 1 # = means we don't need to shift args!
2355023550
else
23551-
echo "$2"
23551+
safe_echo "${2}"
2355223552
return 0 # we need to shift
2355323553
fi
2355423554
}
@@ -24205,13 +24205,16 @@ parse_cmd_line() {
2420524205
[[ $CMDLINE_IP == one ]] && ( is_ipv4addr "$URI" || is_ipv6addr "$URI" ) && fatal_cmd_line "\"--ip=one\" plus supplying an IP address doesn't work" $ERR_CMDLINE
2420624206
"$do_mx_all_ips" && [[ "$NODNS" == none ]] && fatal_cmd_line "\"--mx\" and \"--nodns=none\" don't work together" $ERR_CMDLINE
2420724207

24208-
if [[ -d $ADDTL_CA_FILES ]]; then
24208+
if [[ "${ADDTL_CA_FILES}" =~ \ ]]; then
24209+
fatal_cmd_line "The CA file \"${ADDTL_CA_FILES}\" must not contain spaces" $ERR_RESOURCE
24210+
fi
24211+
if [[ -d "${ADDTL_CA_FILES}" ]]; then
2420924212
ADDTL_CA_FILES="$ADDTL_CA_FILES/*.pem"
2421024213
else
2421124214
ADDTL_CA_FILES="${ADDTL_CA_FILES//,/ }"
2421224215
fi
24213-
for fname in $ADDTL_CA_FILES; do
24214-
[[ -s "$fname" ]] || fatal_cmd_line "CA file \"$fname\" does not exist" $ERR_RESOURCE
24216+
for fname in ${ADDTL_CA_FILES}; do
24217+
[[ -s "$fname" ]] || fatal_cmd_line "The CA file \"$fname\" does not exist" $ERR_RESOURCE
2421524218
grep -q 'BEGIN CERTIFICATE' "$fname" || fatal_cmd_line "\"$fname\" is not CA file in PEM format" $ERR_RESOURCE
2421624219
done
2421724220

0 commit comments

Comments
 (0)