Skip to content

Commit b6de2d3

Browse files
committed
src/ssl.c: in wolfSSL_check_domain_name(), call wolfssl_local_IsValidFQDN() to validate the argument, with allowance for "localhost".
scripts/crl-revoked.test: improve "Workaround to not pollute the certs folder" (don't copy whole source tree, and don't copy file contents).
1 parent 980fc51 commit b6de2d3

2 files changed

Lines changed: 25 additions & 13 deletions

File tree

scripts/crl-revoked.test

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ elif [ "${AM_BWRAPPED-}" != "yes" ]; then
2929
unset AM_BWRAPPED
3030
fi
3131

32-
# Workaround to not pollute the certs folder with our files that can impact other tests
33-
RUNNING_DIR=$(mktemp -d)
34-
cp -rp . $RUNNING_DIR/.
35-
cd $RUNNING_DIR
36-
3732
revocation_code="-361"
3833
revocation_code_openssl="23"
3934
exit_code=1
@@ -49,13 +44,9 @@ server_pid=$no_pid
4944
# also let's add some randomness by adding pid in case multiple 'make check's
5045
# per source tree
5146
ready_file=`pwd`/wolfssl_crl_ready$$
52-
CERT_DIR=certs
5347

5448
remove_ready_file() {
55-
if test -e "$ready_file"; then
56-
echo -e "removing existing ready file"
57-
rm "$ready_file"
58-
fi
49+
rm -f "$ready_file"
5950
}
6051

6152
# trap this function so if user aborts with ^C or other kill signal we still
@@ -84,10 +75,20 @@ trap abort_trap INT TERM
8475
# instead use "exit <some value>" and this function will run automatically
8576
restore_file_system() {
8677
remove_ready_file
87-
cd / && rm -rf "$RUNNING_DIR"
78+
if [ -n "$TMP_DIR" ]; then
79+
rm -rf "$TMP_DIR"
80+
fi
8881
}
8982
trap restore_file_system EXIT
9083

84+
# Workaround to not pollute the certs folder with our files that can impact other tests
85+
TMP_DIR=$(mktemp -d) || exit $?
86+
SRC_DIR="$PWD"
87+
pushd "$TMP_DIR" || exit $?
88+
cp -r --symbolic-link "${SRC_DIR}/certs" . || exit $?
89+
popd || exit $?
90+
CERT_DIR="${TMP_DIR}/certs"
91+
9192
run_test() {
9293
echo -e "\nStarting example server for crl test...\n"
9394

@@ -121,7 +122,7 @@ run_test() {
121122
crl_port="$(cat "$ready_file")"
122123

123124
# starts client on crl_port and captures the output from client
124-
capture_out=$(./examples/client/client -p $crl_port 2>&1)
125+
capture_out=$(cd "${CERT_DIR}/.." && "${SRC_DIR}/examples/client/client" -p $crl_port 2>&1)
125126
client_result=$?
126127

127128
wait $server_pid
@@ -187,7 +188,7 @@ run_hashdir_test() {
187188
crl_port="$(cat "$ready_file")"
188189

189190
# starts client on crl_port and captures the output from client
190-
capture_out=$(./examples/client/client -p $crl_port -9 2>&1)
191+
capture_out=$(cd "${CERT_DIR}/.." && "${SRC_DIR}/examples/client/client" -p $crl_port -9 2>&1)
191192
client_result=$?
192193

193194
wait $server_pid

src/ssl.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7718,13 +7718,24 @@ int wolfSSL_Cleanup(void)
77187718
WOLFSSL_ABI
77197719
int wolfSSL_check_domain_name(WOLFSSL* ssl, const char* dn)
77207720
{
7721+
size_t dn_len;
7722+
77217723
WOLFSSL_ENTER("wolfSSL_check_domain_name");
77227724

77237725
if (ssl == NULL || dn == NULL) {
77247726
WOLFSSL_MSG("Bad function argument: NULL");
77257727
return WOLFSSL_FAILURE;
77267728
}
77277729

7730+
dn_len = XSTRLEN(dn);
7731+
7732+
if ((! wolfssl_local_IsValidFQDN(dn, (word32)dn_len)) &&
7733+
(strcmp(dn, "localhost") != 0))
7734+
{
7735+
WOLFSSL_MSG("Bad function argument: fails wolfssl_local_IsValidFQDN");
7736+
return WOLFSSL_FAILURE;
7737+
}
7738+
77287739
if (ssl->buffers.domainName.buffer)
77297740
XFREE(ssl->buffers.domainName.buffer, ssl->heap, DYNAMIC_TYPE_DOMAIN);
77307741

0 commit comments

Comments
 (0)