From 466cb7921c8efa054369db4bab0eb0150c75ad55 Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Sun, 16 Nov 2014 17:28:55 +0100 Subject: [PATCH] Option ignoreeof on the right address hung --- CHANGES | 4 ++++ socat.c | 3 +++ test.sh | 44 ++++++++++++++++++++++++++++++++++++++------ 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index 9f0eae6..272a7cb 100644 --- a/CHANGES +++ b/CHANGES @@ -25,6 +25,10 @@ corrections: Fixed return value of nestlex() + Option ignoreeof on the right address hung. + Test: IGNOREEOF_REV + Thanks to Franz Fasching for reporting this bug. + ####################### V 1.7.2.4: corrections: diff --git a/socat.c b/socat.c index c9b5952..e4e73f1 100644 --- a/socat.c +++ b/socat.c @@ -913,6 +913,9 @@ int _socat(void) { if (XIO_RDSTREAM(sock1)->ignoreeof) { mayrd1 = 0; } + if (XIO_RDSTREAM(sock2)->ignoreeof) { + mayrd2 = 0; + } } else if (polling && wasaction) { wasaction = 0; diff --git a/test.sh b/test.sh index 3b47286..e65e257 100755 --- a/test.sh +++ b/test.sh @@ -3552,7 +3552,6 @@ esac N=$((N+1)) -#set -vx NAME=IGNOREEOF case "$TESTS" in *%$N%*|*%functions%*|*%engine%*|*%ignoreeof%*|*%$NAME%*) @@ -3585,7 +3584,40 @@ fi fi ;; # NUMCOND esac N=$((N+1)) -#set +vx + +NAME=IGNOREEOF_REV +case "$TESTS" in +*%$N%*|*%functions%*|*%engine%*|*%ignoreeof%*|*%$NAME%*) +TEST="$NAME: ignoreeof on file right-to-left" +if ! eval $NUMCOND; then :; else +ti="$td/test$N.file" +tf="$td/test$N.stdout" +te="$td/test$N.stderr" +tdiff="$td/test$N.diff" +da="test$N $(date) $RANDOM" +CMD="$SOCAT $opts -U - file:\"$ti\",ignoreeof" +printf "test $F_n $TEST... " $N +touch "$ti" +$CMD >"$tf" 2>"$te" & +bg=$! +usleep 500000 +echo "$da" >>"$ti" +sleep 1 +kill $bg 2>/dev/null +if ! echo "$da" |diff - "$tf" >"$tdiff"; then + $PRINTF "$FAILED: diff:\n" + cat "$tdiff" + listFAIL="$listFAIL $N" + numFAIL=$((numFAIL+1)) +else + $PRINTF "$OK\n" + if [ -n "$debug" ]; then cat $te; fi + numOK=$((numOK+1)) +fi +wait +fi ;; # NUMCOND +esac +N=$((N+1)) NAME=EXECIGNOREEOF @@ -7792,7 +7824,7 @@ N=$((N+1)) NAME=COOLWRITE case "$TESTS" in -*%$N%*|*%functions%*|*%engine%*|*%timeout%*|*%ignoreeof%*|*%coolwrite%*|*%$NAME%*) +*%$N%*|*%functions%*|*%engine%*|*%timeout%*|*%coolwrite%*|*%$NAME%*) TEST="$NAME: option cool-write" if ! eval $NUMCOND; then :; elif ! testoptions cool-write >/dev/null; then @@ -7835,7 +7867,7 @@ N=$((N+1)) # this failed up to socat 1.6.0.0 NAME=COOLSTDIO case "$TESTS" in -*%$N%*|*%functions%*|*%engine%*|*%timeout%*|*%ignoreeof%*|*%coolwrite%*|*%$NAME%*) +*%$N%*|*%functions%*|*%engine%*|*%timeout%*|*%coolwrite%*|*%$NAME%*) TEST="$NAME: option cool-write on bidirectional stdio" # this test starts a socat reader that terminates after receiving one+ # bytes (option readbytes); and a test process that sends two bytes via @@ -11503,7 +11535,7 @@ if [ "$fileopt" = "." ]; then fileopt=; fi if [ "$addropts" = "." ]; then addropts=; fi NAME=${ADDR_}_PERM case "$TESTS" in -*%$N%*|*%functions%*|*%bugs%*|*%proto%*|*%socket%*|*%$proto%*|*%$NAME%*) +*%$N%*|*%functions%*|*%bugs%*|*%proto%*|*%socket%*|*%$proto%*|*%ignoreeof%*|*%$NAME%*) TEST="$NAME: $ADDR applies option perm" # start a socat process with passive/listening file system entry. Check the # permissions of the FS entry, then terminate the process. @@ -11575,7 +11607,7 @@ if [ "$fileopt" = "." ]; then fileopt=; fi if [ "$addropts" = "." ]; then addropts=; fi NAME=${ADDR_}_USER case "$TESTS" in -*%$N%*|*%functions%*|*%bugs%*|*%proto%*|*%socket%*|*%$proto%*|*%root%*|*%$NAME%*) +*%$N%*|*%functions%*|*%bugs%*|*%proto%*|*%socket%*|*%$proto%*|*%root%*|*%ignoreeof%*|*%$NAME%*) TEST="$NAME: $ADDR applies option user" # start a socat process with passive/listening file system entry with user option. # Check the owner of the FS entry, then terminate the process.