OPENSSL-CONNECT with bind option failed on some systems with Invalid argument

This commit is contained in:
Gerhard Rieger 2014-03-21 13:24:26 +01:00
parent 7e696b4b3e
commit 3f207a2e70
3 changed files with 56 additions and 1 deletions

View file

@ -16,6 +16,10 @@ corrections:
digits. Thanks to Frank Dana for providing a patch that increases field digits. Thanks to Frank Dana for providing a patch that increases field
width to 24 digits. width to 24 digits.
OPENSSL-CONNECT with bind option failed on some systems, eg.FreeBSD, with
"Invalid argument"
Thanks to Emile den Tex for reporting this bug.
fixed bug in xio-openssl.c that prevented error handling of bad number fixed bug in xio-openssl.c that prevented error handling of bad number
of arguments, thanks to Paulik Tamas for reporting of arguments, thanks to Paulik Tamas for reporting

51
test.sh
View file

@ -11622,6 +11622,57 @@ PORT=$((PORT+1))
N=$((N+1)) N=$((N+1))
# OPENSSL-CONNECT with bind option failed on some systems (eg.FreeBSD, but not
# Linux) with "Invalid argument".
NAME=OPENSSL_CONNECT_BIND
case "$TESTS" in
*%functions%*|*%bugs%*|*%socket%*|*%ssl%*|*%$NAME%*)
TEST="$NAME: test OPENSSL-CONNECT with bind option"
# have a simple SSL server that just echoes data.
# connect with socat using OPENSSL-CONNECT with bind, send data and check if the
# reply is identical.
if ! eval $NUMCOND; then :; else
tf0="$td/test$N.0.stdout"
te0="$td/test$N.0.stderr"
tf1="$td/test$N.1.stdout"
te1="$td/test$N.1.stderr"
tdiff="$td/test$N.diff"
da="test$N $(date) $RANDOM"
CMD0="$SOCAT $opts OPENSSL-LISTEN:$PORT,reuseaddr,ciphers=aNULL,verify=0, PIPE"
CMD1="$SOCAT $opts - OPENSSL-CONNECT:$LOCALHOST:$PORT,bind=$LOCALHOST,ciphers=aNULL,verify=0"
printf "test $F_n $TEST... " $N
$CMD0 >/dev/null 2>"$te0" &
pid0=$!
waittcp4port $PORT 1
echo "$da" |$CMD1 >"$tf1" 2>"$te1"
rc1=$?
kill $pid0 2>/dev/null; wait
if [ "$rc1" -ne 0 ]; then
$PRINTF "$FAILED\n"
echo "$CMD0 &"
echo "$CMD1"
cat "$te0"
cat "$te1"
numFAIL=$((numFAIL+1))
elif ! echo "$da" |diff - $tf1 >"$tdiff"; then
$PRINTF "$FAILED\n"
echo "$CMD0 &"
echo "$CMD1"
cat "${te}0"
cat "${te}1"
cat "$tdiff"
numFAIL=$((numFAIL+1))
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 # here come tests that might affect your systems integrity. Put normal tests
# before this paragraph. # before this paragraph.

View file

@ -348,7 +348,7 @@ static int
/* this cannot fork because we retrieved fork option above */ /* this cannot fork because we retrieved fork option above */
result = result =
_xioopen_connect(xfd, _xioopen_connect(xfd,
needbind?(struct sockaddr *)us:NULL, sizeof(*us), needbind?(struct sockaddr *)us:NULL, uslen,
(struct sockaddr *)them, themlen, (struct sockaddr *)them, themlen,
opts, pf, socktype, ipproto, lowport, level); opts, pf, socktype, ipproto, lowport, level);
switch (result) { switch (result) {