From 0ab324b1733fb5c2da42a216008cdff5a794cd38 Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Mon, 12 Jan 2015 22:20:35 +0100 Subject: [PATCH] Address SYSTEM, when terminating, shutted down its parent addresses --- CHANGES | 4 ++++ test.sh | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ xio-system.c | 6 +++++- 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 272a7cb..263253f 100644 --- a/CHANGES +++ b/CHANGES @@ -29,6 +29,10 @@ corrections: Test: IGNOREEOF_REV Thanks to Franz Fasching for reporting this bug. + Address SYSTEM, when terminating, shutted down its parent addresses, + e.g. an SSL connection which the parent assumed to still be active. + Test: SYSTEM_SHUTDOWN + ####################### V 1.7.2.4: corrections: diff --git a/test.sh b/test.sh index e65e257..f127900 100755 --- a/test.sh +++ b/test.sh @@ -11804,6 +11804,61 @@ unix-recvfrom . . unixport . -e FILE:/dev/null " +# bug fix: SYSTEM address child process shutted down parents sockets including +# SSL connection under some circumstances. +NAME=SYSTEM_SHUTDOWN +case "$TESTS" in +*%$N%*|*%functions%*|*%bugs%*|*%system%*|*%openssl%*|*%socket%*|*%$NAME%*) +TEST="$NAME: SYSTEM address does not shutdown its parents addresses" +# start an OpenSSL echo server using SYSTEM:cat +# start an OpenSSL client that sends data +# when the client recieves its data and terminates without error the test succeeded +# in case of the bug the client issues an error like: +# SSL_connect(): error:1408F119:SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac +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" +CMD0="$SOCAT $opts OPENSSL-LISTEN:$PORT,reuseaddr,cipher=aNULL,verify=0 SYSTEM:cat" +CMD1="$SOCAT $opts - OPENSSL-CONNECT:$LOCALHOST:$PORT,cipher=aNULL,verify=0" +printf "test $F_n $TEST... " $N +$CMD0 >/dev/null 2>"${te}0" & +pid0=$! +waittcp4port $PORT 1 +echo "$da" |$CMD1 >"${tf}1" 2>"${te}1" +rc1=$? +kill $pid0 2>/dev/null; wait +if [ $rc1 -ne 0 ]; then + $PRINTF "$FAILED\n" + echo "rc1=$rc1" + echo "$CMD0 &" + echo "$CMD1" + cat "${te}0" + cat "${te}1" + numFAIL=$((numFAIL+1)) + listFAIL="$listFAIL $N" +elif ! echo "$da" |diff - "${tf}1" >"$tdiff" 2>&1; then + $PRINTF "$FAILED\n" + echo "diff:" + cat "$tdiff" + echo "$CMD0 &" + echo "$CMD1" + cat "${te}0" + cat "${te}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 diff --git a/xio-system.c b/xio-system.c index 39a5193..721f130 100644 --- a/xio-system.c +++ b/xio-system.c @@ -1,5 +1,5 @@ /* source: xio-system.c */ -/* Copyright Gerhard Rieger 2001-2008 */ +/* Copyright Gerhard Rieger */ /* Published under the GNU General Public License V.2, see file COPYING */ /* this file contains the source for opening addresses of system type */ @@ -40,6 +40,10 @@ static int xioopen_system(int argc, const char *argv[], struct opt *opts, if (status == 0) { /* child */ int numleft; + /* do not shutdown connections that belong our parent */ + sock[0] = NULL; + sock[1] = NULL; + if (setopt_path(opts, &path) < 0) { /* this could be dangerous, so let us abort this child... */ Exit(1);