From 5ebf36038f3960798e769bff5646e755a91a1119 Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Mon, 30 Dec 2019 10:27:46 +0100 Subject: [PATCH] Under certain circumstances, options of the first address were applied to the second address --- CHANGES | 6 ++++++ test.sh | 34 ++++++++++++++++++++++++++++++++++ xioopts.c | 2 +- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 1e5d16a..2861256 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,12 @@ Corrections: Thanks to Joe Strout and others for reporting this bug. Thanks to Andrew Childs and others for sending a patch. + Under certain circumstances, termios options of the first address were + applied to the second address, resulting in error + "Inappropriate ioctl for device" + This affected version 1.7.3.3 only. + Thanks to Ivan J. for reporting this issue. + ####################### V 1.7.3.3: Corrections: diff --git a/test.sh b/test.sh index 2be851e..30d1a25 100755 --- a/test.sh +++ b/test.sh @@ -13027,6 +13027,40 @@ esac N=$((N+1)) +# test for a bug in Socat version 1.7.3.3 where +# termios options of the first address were applied to the second address. +NAME=TERMIOS_PH_ALL +case "$TESTS" in +*%$N%*|*%functions%*|*%bugs%*|*%termios%*|*%$NAME%*) +TEST="$NAME: are termios options applied to the correct address" +# add a termios option to the first address, a tty, and have a second address +# with pipe. If no error occurs the termios option was not applied to the pipe, +# thus the test succeeded. +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="$TRACE $SOCAT $opts -T 1 STDIO,echo=0 EXEC:cat" +printf "test $F_n $TEST... " $N +$CMD0 2>"${te}0" +rc0=$? +if [ $rc0 -eq 0 ]; then + $PRINTF "$OK\n" + numOK=$((numOK+1)) +else + $PRINTF "$FAILED\n" + echo "$CMD0" + numFAIL=$((numFAIL+1)) + listFAIL="$listFAIL $N" +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/xioopts.c b/xioopts.c index 56b46c4..e11e9c0 100644 --- a/xioopts.c +++ b/xioopts.c @@ -3581,7 +3581,7 @@ int applyopts(int fd, struct opt *opts, enum e_phase phase) { } #if WITH_TERMIOS - if (phase == PH_FD) { + if (phase == PH_FD || phase == PH_ALL) { xiotermios_flush(fd); } #endif /* WITH_TERMIOS */