1
0
Fork 0
mirror of https://repo.or.cz/socat.git synced 2025-06-09 11:16:51 +00:00

UNIX-L with bind option logged INTERNAL error

This commit is contained in:
Gerhard 2025-02-08 20:55:03 +01:00
parent ed11b3d2c5
commit 676888e8cc
3 changed files with 62 additions and 0 deletions

View file

@ -56,6 +56,10 @@ Corrections:
Nanosleep() trace output now in decimal form.
UNIX-LISTEN with bind option terminated with INTERNAL error, this is
now handled properly.
Test: UNIX_L_BIND
Features:
POSIXMQ-RECV now takes option o-nonblock; this, in combination with -T,
makes it possible to terminate Socat in case the queue is empty.

51
test.sh
View file

@ -19446,6 +19446,57 @@ esac
N=$((N+1))
# Test for useful error message on UNIX-L with bind option
NAME=UNIX_L_BIND
case "$TESTS" in
*%$N%*|*%functions%*|*%bugs%*|*%socket%*|*%listen%*|*%unix%*|*%bind%*|*%$NAME%*)
TEST="$NAME: Test if UNIX-L with bind does not fail INTERNAL"
# Invoke Socat with a UNIX-LISTEN address with bind option.
# When there is no INTERNAL error the test succeeded.
if ! eval $NUMCOND; then :
elif ! cond=$(checkconds \
"" \
"" \
"" \
"UNIX LISTEN PIPE" \
"UNIX-LISTEN PIPE" \
"bind,accept-timeout" \
"" ); then
$PRINTF "test $F_n $TEST... ${YELLOW}$cond${NORMAL}\n" $N
cant
else
ts="$td/test$N.sock"
tb="$td/test$N.bind"
tf="$td/test$N.stdout"
te="$td/test$N.stderr"
tdiff="$td/test$N.diff"
da="test$N $(date) $RANDOM"
CMD0="$TRACE $SOCAT $opts UNIX-LISTEN:$ts,accept-timeout=0.001,bind=$tb PIPE"
printf "test $F_n $TEST... " $N
$CMD0 >/dev/null 2>"${te}0"
rc0=$?
if [ "$rc0" -eq 0 ]; then
$PRINTF "$CANT (rc0=$rc0)\n"
echo "$CMD0"
cat "${te}0" >&2
cant
elif grep " E .* INTERNAL " "${te}0" >/dev/null; then
$PRINTF "$FAILED (INTERNAL)\n"
echo "$CMD0"
cat "${te}0" >&2
failed
else
$PRINTF "$OK\n"
if [ "$VERBOSE" ]; then echo "$CMD0 &"; fi
if [ "$DEBUG" ]; then cat "${te}0" >&2; fi
ok
fi
fi # NUMCOND
;;
esac
N=$((N+1))
# end of common tests
##################################################################################

View file

@ -123,6 +123,7 @@ static int xioopen_unix_listen(
/* we expect the form: filename */
const char *name;
xiosingle_t *sfd = &xxfd->stream;
char *bindstring = NULL;
int pf = PF_UNIX;
int socktype = SOCK_STREAM;
int protocol = 0;
@ -140,6 +141,12 @@ static int xioopen_unix_listen(
}
name = argv[1];
if (retropt_string(opts, OPT_BIND, &bindstring) == 0) {
Error2("%s:%s: binds implicitly, bind option not allowed",
addrdesc->defname, argv[1]);
free(bindstring);
}
sfd->para.socket.un.tight = UNIX_TIGHTSOCKLEN;
retropt_socket_pf(opts, &pf);
if (sfd->howtoend == END_UNSPEC)