mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-10-24 04:09:07 +03:00
Three ways the bounds added here failed to do their job: - get_first_free_port ended the scan cap with 'exit 1', but every caller runs it in a command substitution, so only the subshell died. The port variable came back empty, the next $((port + 1)) evaluated to 1, and the run limped on to a confusing wait_for_readyFile failure. Forcing the cap on ocsp-stapling.test: before, the script ran on and hung until an outer timeout killed it; now it exits 1 at the error. Return instead, and check the status at all 25 call sites across the six scripts. - The macOS timeout shim was a shell function. Backgrounding a function forks a subshell, so $! was the subshell and cleanup killed that while the server it was meant to stop leaked. Use a prefix variable that expands to nothing when timeout(1) is absent, keeping $! the real pid. - timeout -s KILL exits 137, not 124. Sites that read $? and treat any non-zero as 'feature not compiled in' turned a hang into exit 0, so the bound made a hang less visible than before. Add timed_out() and check it before those skip branches; use it for the version probes too, which matched any status >= 124.
81 lines
2.4 KiB
Bash
Executable File
81 lines
2.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# timeout(1) is GNU coreutils and absent on macOS; where it's missing, run the
|
|
# command unbounded (the flaky hang this guards against is Linux-only CI).
|
|
# A prefix variable rather than a shell function: backgrounding a function
|
|
# makes $! the forked subshell, so a later "kill $server_pid" would stop the
|
|
# wrapper and orphan the server it was meant to kill.
|
|
if command -v timeout >/dev/null 2>&1; then
|
|
TIMEOUT_KILL_2M="timeout -s KILL 2m"
|
|
else
|
|
TIMEOUT_KILL_2M=""
|
|
fi
|
|
|
|
|
|
# dtlscid.test
|
|
# Copyright wolfSSL 2022-2024
|
|
|
|
[ ! -x ./examples/client/client ] && printf '\n\n%s\n' "Client doesn't exist" \
|
|
&& exit 0
|
|
|
|
[ ! -x ./examples/server/server ] && printf '\n\n%s\n' "Server doesn't exist" \
|
|
&& exit 0
|
|
|
|
if ./examples/client/client -? 2>&1 | grep "Client not compiled in!" ; then
|
|
echo 'skipping dtlscid.test because client not compiled in.' 1>&2
|
|
exit 77
|
|
fi
|
|
|
|
if ./examples/server/server -? 2>&1 | grep "Server not compiled in!" ; then
|
|
echo 'skipping dtlscid.test because server not compiled in.' 1>&2
|
|
exit 77
|
|
fi
|
|
|
|
# if we can, isolate the network namespace to eliminate port collisions.
|
|
if [[ -n "$NETWORK_UNSHARE_HELPER" ]]; then
|
|
if [[ -z "$NETWORK_UNSHARE_HELPER_CALLED" ]]; then
|
|
export NETWORK_UNSHARE_HELPER_CALLED=yes
|
|
exec "$NETWORK_UNSHARE_HELPER" "$0" "$@" || exit $?
|
|
fi
|
|
elif [ "${AM_BWRAPPED-}" != "yes" ]; then
|
|
bwrap_path="$(command -v bwrap)"
|
|
if [ -n "$bwrap_path" ]; then
|
|
export AM_BWRAPPED=yes
|
|
exec "$bwrap_path" --unshare-net --dev-bind / / "$0" "$@"
|
|
fi
|
|
unset AM_BWRAPPED
|
|
fi
|
|
|
|
cleanup () {
|
|
echo "Cleaning up..."
|
|
if [ ! -z "$SERVER_PID" ];then
|
|
echo "Killing server $SERVER_PID"
|
|
kill $SERVER_PID
|
|
fi
|
|
}
|
|
|
|
trap cleanup err exit
|
|
|
|
CCID="AA"
|
|
SCID="BB"
|
|
HEXCID=$(printf $CCID | od -An -tx1 | tr -d ' \n')
|
|
HEXSCID=$(printf $SCID | od -An -tx1 | tr -d ' \n')
|
|
WOLFSSL_ROOT=$(pwd)
|
|
|
|
test_cid () {
|
|
echo "Running test_cid"
|
|
SERVER_FILE=$(mktemp)
|
|
CLIENT_FILE=$(mktemp)
|
|
$TIMEOUT_KILL_2M $WOLFSSL_ROOT/examples/server/server -v4 -u --cid $SCID 1> $SERVER_FILE &
|
|
SERVER_PID=$!
|
|
sleep 0.2
|
|
$TIMEOUT_KILL_2M $WOLFSSL_ROOT/examples/client/client -v4 -u --cid $CCID 1> $CLIENT_FILE
|
|
wait $SERVER_PID
|
|
SERVER_PID=
|
|
grep "Sending CID is ${HEXSCID}" $CLIENT_FILE > /dev/null
|
|
grep "Sending CID is ${HEXCID}" $SERVER_FILE > /dev/null
|
|
echo "test_cid has passed"
|
|
}
|
|
|
|
test_cid
|