mirror of
https://repo.or.cz/socat.git
synced 2024-12-22 15:32:35 +00:00
Print error on useless fdout,fdin options
This commit is contained in:
parent
9d93ce10b7
commit
8e58611133
3 changed files with 49 additions and 2 deletions
5
CHANGES
5
CHANGES
|
@ -213,6 +213,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:
|
||||
Red Hat issue 1020203: configure checks fail with some compilers.
|
||||
Use case: clang
|
||||
|
|
33
test.sh
33
test.sh
|
@ -12537,6 +12537,39 @@ N=$((N+1))
|
|||
done
|
||||
|
||||
|
||||
# test if option fdout in write only context issues an error
|
||||
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
|
||||
# before this paragraph.
|
||||
|
|
|
@ -164,8 +164,17 @@ int _xioopen_progcall(int xioflags, /* XIO_RDONLY etc. */
|
|||
if (!retropt_int(popts, OPT_LEFTFD, &fdi)) {
|
||||
fdo = fdi;
|
||||
}
|
||||
retropt_int(popts, OPT_LEFTINFD, &fdi);
|
||||
retropt_int(popts, OPT_LEFTOUTFD, &fdo);
|
||||
|
||||
if (retropt_int(popts, OPT_LEFTINFD, (unsigned short *)&fdi) >= 0) {
|
||||
if ((xioflags&XIO_ACCMODE) == XIO_RDONLY) {
|
||||
Error("_xioopen_progcall(): option fdin is useless in read-only mode");
|
||||
}
|
||||
}
|
||||
if (retropt_int(popts, OPT_LEFTOUTFD, (unsigned short *)&fdo) >= 0) {
|
||||
if ((xioflags&XIO_ACCMODE) == XIO_WRONLY) {
|
||||
Error("_xioopen_progcall(): option fdout is useless in write-only mode");
|
||||
}
|
||||
}
|
||||
|
||||
if (!retropt_int(popts, OPT_RIGHTFD, &rightin)) {
|
||||
rightout = rightin;
|
||||
|
|
Loading…
Reference in a new issue