Address SYSTEM, when terminating, shutted down its parent addresses

This commit is contained in:
Gerhard Rieger 2015-04-01 14:39:54 +02:00
parent 5bf034ba87
commit 346a6df6c0
3 changed files with 64 additions and 1 deletions

View file

@ -172,6 +172,10 @@ corrections:
Test: IGNOREEOF_REV Test: IGNOREEOF_REV
Thanks to Franz Fasching for reporting this bug. 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
porting: porting:
Red Hat issue 1020203: configure checks fail with some compilers. Red Hat issue 1020203: configure checks fail with some compilers.
Use case: clang Use case: clang

55
test.sh
View file

@ -12188,6 +12188,61 @@ unix-recvfrom . . unixport . -e FILE:/dev/null
" "
# bug fix: SYSTEM address child process shut 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 # here come tests that might affect your systems integrity. Put normal tests
# before this paragraph. # before this paragraph.

View file

@ -1,5 +1,5 @@
/* source: xio-system.c */ /* source: xio-system.c */
/* Copyright Gerhard Rieger 2001-2009 */ /* Copyright Gerhard Rieger */
/* Published under the GNU General Public License V.2, see file COPYING */ /* Published under the GNU General Public License V.2, see file COPYING */
/* this file contains the source for opening addresses of system type */ /* this file contains the source for opening addresses of system type */
@ -64,6 +64,10 @@ static int xioopen_system(int argc, const char *argv[], struct opt *opts,
if (status == 0) { /* child */ if (status == 0) { /* child */
int numleft; int numleft;
/* do not shutdown connections that belong our parent */
sock[0] = NULL;
sock[1] = NULL;
if (setopt_path(opts, &path) < 0) { if (setopt_path(opts, &path) < 0) {
/* this could be dangerous, so let us abort this child... */ /* this could be dangerous, so let us abort this child... */
Exit(1); Exit(1);