mirror of
https://repo.or.cz/socat.git
synced 2024-12-22 23:42:34 +00:00
Print error on useless fdout,fdin options
This commit is contained in:
parent
2b99929bfc
commit
8c8f817780
3 changed files with 49 additions and 2 deletions
5
CHANGES
5
CHANGES
|
@ -81,6 +81,11 @@ corrections:
|
|||
Help for filan -L was bad, is now corrected to:
|
||||
"follow symbolic links instead of showing their properties"
|
||||
|
||||
Address options fdin and fdout were silently ignored when not applicable
|
||||
due to -u or -U option. Now these combinations are caught as errors.
|
||||
Test: FDOUT_ERROR
|
||||
Issue reported by Hendrik.
|
||||
|
||||
porting:
|
||||
Socat included <sys/poll.h> instead of POSIX <poll.h>
|
||||
Thanks to John Spencer for reporting this issue.
|
||||
|
|
33
test.sh
33
test.sh
|
@ -12149,6 +12149,39 @@ N=$((N+1))
|
|||
done
|
||||
|
||||
|
||||
# give a description of what is tested (a bugfix, a new feature...)
|
||||
NAME=FDOUT_ERROR
|
||||
case "$TESTS" in
|
||||
*%$N%*|*%functions%*|*%bugs%*|*%socket%*|*%$NAME%*)
|
||||
TEST="$NAME: fdout bails out in write-only context"
|
||||
# use EXEC in write-only context with option fdout. Expected behaviour: error
|
||||
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"
|
||||
CMD="$SOCAT $opts -u /dev/null EXEC:cat,fdout=1"
|
||||
printf "test $F_n $TEST... " $N
|
||||
$CMD >/dev/null 2>"${te}"
|
||||
rc=$?
|
||||
if [ $rc -eq 1 ]; then
|
||||
$PRINTF "$OK\n"
|
||||
numOK=$((numOK+1))
|
||||
else
|
||||
$PRINTF "$FAILED\n"
|
||||
echo "$CMD"
|
||||
cat "${te}"
|
||||
echo "command did not terminate with error!"
|
||||
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
|
||||
|
|
|
@ -103,8 +103,17 @@ int _xioopen_foxec(int xioflags, /* XIO_RDONLY etc. */
|
|||
usepipes = false;
|
||||
}
|
||||
#endif /* HAVE_PTY */
|
||||
retropt_ushort(popts, OPT_FDIN, (unsigned short *)&fdi);
|
||||
retropt_ushort(popts, OPT_FDOUT, (unsigned short *)&fdo);
|
||||
|
||||
if (retropt_ushort(popts, OPT_FDIN, (unsigned short *)&fdi) >= 0) {
|
||||
if ((xioflags&XIO_ACCMODE) == XIO_RDONLY) {
|
||||
Error("_xioopen_foxec(): option fdin is useless in read-only mode");
|
||||
}
|
||||
}
|
||||
if (retropt_ushort(popts, OPT_FDOUT, (unsigned short *)&fdo) >= 0) {
|
||||
if ((xioflags&XIO_ACCMODE) == XIO_WRONLY) {
|
||||
Error("_xioopen_foxec(): option fdout is useless in write-only mode");
|
||||
}
|
||||
}
|
||||
|
||||
if (withfork) {
|
||||
if (!(xioflags&XIO_MAYCHILD)) {
|
||||
|
|
Loading…
Reference in a new issue