mirror of
https://github.com/moparisthebest/socat
synced 2024-12-21 22:48:48 -05:00
Passive addresses like TCP-LISTEN with empty port bound to random
This commit is contained in:
parent
0ab324b173
commit
ad524a56b7
4
CHANGES
4
CHANGES
@ -33,6 +33,10 @@ corrections:
|
||||
e.g. an SSL connection which the parent assumed to still be active.
|
||||
Test: SYSTEM_SHUTDOWN
|
||||
|
||||
Passive (listening or receiving) addresses with empty port field bound
|
||||
to a random port instead of terminating with error.
|
||||
Test: TCP4_NOPORT
|
||||
|
||||
####################### V 1.7.2.4:
|
||||
|
||||
corrections:
|
||||
|
44
test.sh
44
test.sh
@ -11859,6 +11859,50 @@ PORT=$((PORT+1))
|
||||
N=$((N+1))
|
||||
|
||||
|
||||
# test if TCP4-LISTEN with empty port arg terminates with error
|
||||
NAME=TCP4_NOPORT
|
||||
case "$TESTS" in
|
||||
*%$N%*|*%functions%*|*%bugs%*|*%socket%*|*%tcp%*|*%tcp4%*|*%$NAME%*)
|
||||
TEST="$NAME: test if TCP4-LISTEN with empty port arg bails out"
|
||||
# run socat with TCP4-LISTEN with empty port arg. Check if it terminates
|
||||
# immediately with return code 1
|
||||
if ! eval $NUMCOND; then :; else
|
||||
tf="$td/test$N.stdout"
|
||||
te="$td/test$N.stderr"
|
||||
t0rc="$td/test$N.rc"
|
||||
tdiff="$td/test$N.diff"
|
||||
da="test$N $(date) $RANDOM"
|
||||
CMD0="$SOCAT $opts TCP4-LISTEN: /dev/null"
|
||||
printf "test $F_n $TEST... " $N
|
||||
{ $CMD0 >/dev/null 2>"${te}0"; echo $? >"$t0rc"; } & 2>/dev/null
|
||||
pid0=$!
|
||||
sleep 1
|
||||
kill $pid0 2>/dev/null; wait
|
||||
if [ ! -f "$t0rc" ]; then
|
||||
$PRINTF "$FAILED\n"
|
||||
echo "$CMD0 &"
|
||||
cat "${te}0"
|
||||
echo "did not terminate with error"
|
||||
numFAIL=$((numFAIL+1))
|
||||
listFAIL="$listFAIL $N"
|
||||
elif ! echo 1 |diff - "$t0rc"; then
|
||||
$PRINTF "$FAILED\n"
|
||||
echo "$CMD0 &"
|
||||
cat "${te}0"
|
||||
echo "expected return code 1"
|
||||
numFAIL=$((numFAIL+1))
|
||||
listFAIL="$listFAIL $N"
|
||||
else
|
||||
$PRINTF "$OK\n"
|
||||
numOK=$((numOK+1))
|
||||
fi
|
||||
fi # NUMCOND
|
||||
;;
|
||||
esac
|
||||
PORT=$((PORT+1))
|
||||
N=$((N+1))
|
||||
|
||||
|
||||
##################################################################################
|
||||
#=================================================================================
|
||||
# here come tests that might affect your systems integrity. Put normal tests
|
||||
|
3
xio-ip.c
3
xio-ip.c
@ -149,6 +149,9 @@ int xiogetaddrinfo(const char *node, const char *service,
|
||||
memset(sau, 0, *socklen);
|
||||
sau->soa.sa_family = family;
|
||||
|
||||
if (service && service[0]=='\0') {
|
||||
Error("empty port/service");
|
||||
}
|
||||
/* if service is numeric we don't want to have a lookup (might take long
|
||||
with NIS), so we handle this specially */
|
||||
if (service && isdigit(service[0]&0xff)) {
|
||||
|
Loading…
Reference in New Issue
Block a user