mirror of
https://repo.or.cz/socat.git
synced 2024-12-22 23:42:34 +00:00
Catch service resolution failure
This commit is contained in:
parent
3efbf71430
commit
ea5beb8e75
3 changed files with 56 additions and 0 deletions
4
CHANGES
4
CHANGES
|
@ -23,6 +23,10 @@ Corrections:
|
|||
Corrected a typo in configure.ac that broke option --enable-openssl-base
|
||||
Thanks to john1doe for reporting this issue.
|
||||
|
||||
Socat looped endlessly, not responding to SIGTERM, when a service name
|
||||
(for port) could not be resolved.
|
||||
Test: BAD_SERVICE
|
||||
|
||||
Testing:
|
||||
Prevent the TIMESTAMP tests from sporadically failing due do seconds
|
||||
overflow
|
||||
|
|
42
test.sh
42
test.sh
|
@ -15092,6 +15092,44 @@ PORT=$((PORT+1))
|
|||
N=$((N+1))
|
||||
|
||||
|
||||
# Test if unknown service specs are handled properly
|
||||
NAME=BAD_SERVICE
|
||||
case "$TESTS" in
|
||||
*%$N%*|*%functions%*|*%bugs%*|*%tcp%*|*%socket%*|*%$NAME%*)
|
||||
TEST="$NAME: test if unknown service specs are handled properly"
|
||||
# Try to resolve an unspecified TCP service "
|
||||
if ! eval $NUMCOND; then :; else
|
||||
tf="$td/test$N.stdout"
|
||||
te="$td/test$N.stderr"
|
||||
tdiff="$td/test$N.diff"
|
||||
da="test$N $(date) $RANDOM"
|
||||
CMD="$TRACE $SOCAT $opts - TCP:$LOCALHOST:zyxw"
|
||||
printf "test $F_n $TEST... " $N
|
||||
$CMD >/dev/null 2>"${te}" &
|
||||
pid=$!
|
||||
sleep 1
|
||||
kill -9 $pid 2>/dev/null;
|
||||
rc=$? # did process still exist?
|
||||
if [ $rc -ne 0 ]; then
|
||||
$PRINTF "$OK\n"
|
||||
if [" $VERBOSE" ]; then
|
||||
echo "$CMD &" >&2
|
||||
fi
|
||||
numOK=$((numOK+1))
|
||||
else
|
||||
$PRINTF "$FAILED\n"
|
||||
echo "$CMD &" >&2
|
||||
cat "${te}" >&2
|
||||
numFAIL=$((numFAIL+1))
|
||||
listFAIL="$listFAIL $N"
|
||||
fi
|
||||
fi # NUMCOND
|
||||
;;
|
||||
esac
|
||||
PORT=$((PORT+1))
|
||||
N=$((N+1))
|
||||
|
||||
|
||||
# end of common tests
|
||||
|
||||
##################################################################################
|
||||
|
@ -15215,6 +15253,10 @@ rc1=$?
|
|||
kill $pid0 2>/dev/null; wait
|
||||
if [ !!! ]; then
|
||||
$PRINTF "$OK\n"
|
||||
if [" $VERBOSE" ]; then
|
||||
echo "$CMD0 &" >&2
|
||||
echo "$CMD1" >&2
|
||||
fi
|
||||
numOK=$((numOK+1))
|
||||
else
|
||||
$PRINTF "$FAILED\n"
|
||||
|
|
10
xio-ip.c
10
xio-ip.c
|
@ -238,6 +238,16 @@ int xiogetaddrinfo(const char *node, const char *service,
|
|||
continue;
|
||||
}
|
||||
if (error_num == EAI_SERVICE && protocol != 0) {
|
||||
if (hints.ai_protocol == 0) {
|
||||
Error7("getaddrinfo\"%s\", \"%s\", {%d,%d,%d,%d}, {}): %s",
|
||||
node?node:"NULL", service?service:"NULL",
|
||||
hints.ai_flags, hints.ai_family,
|
||||
hints.ai_socktype, hints.ai_protocol,
|
||||
gai_strerror(error_num));
|
||||
if (res != NULL) freeaddrinfo(res);
|
||||
if (numnode) free(numnode);
|
||||
return STAT_NORETRY;
|
||||
}
|
||||
hints.ai_protocol = 0;
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue