diff --git a/CHANGES b/CHANGES index d568f0f..ecc5b93 100644 --- a/CHANGES +++ b/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 diff --git a/test.sh b/test.sh index c0e98a3..753c656 100755 --- a/test.sh +++ b/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" diff --git a/xio-ip.c b/xio-ip.c index d1e8bec..289c68e 100644 --- a/xio-ip.c +++ b/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; }