issue error when PTY called with parameters

This commit is contained in:
Gerhard Rieger 2011-03-10 07:55:03 +01:00
parent aae035c5b9
commit b8d16ecd51
3 changed files with 39 additions and 2 deletions

View file

@ -23,6 +23,9 @@ corrections:
socat option -x did not print packet direction, timestamp etc; thanks socat option -x did not print packet direction, timestamp etc; thanks
to Anthony Sharobaiko for sending a patch to Anthony Sharobaiko for sending a patch
address PTY does not take any parameters but did not report an error
when some were given
####################### V 1.7.1.3: ####################### V 1.7.1.3:
security: security:

32
test.sh
View file

@ -1,6 +1,6 @@
#! /bin/bash #! /bin/bash
# source: test.sh # source: test.sh
# Copyright Gerhard Rieger 2001-2010 # Copyright Gerhard Rieger 2001-2011
# Published under the GNU General Public License V.2, see file COPYING # Published under the GNU General Public License V.2, see file COPYING
# perform lots of tests on socat # perform lots of tests on socat
@ -10409,6 +10409,36 @@ esac
N=$((N+1)) N=$((N+1))
# PTY address allowed to sepcify address parameters but ignored them
NAME=PTY_VOIDARG
case "$TESTS" in
*%functions%*|*%bugs%*|*%pty%*|*%$NAME%*)
TEST="$NAME: check if address params of PTY produce error"
# invoke socat with address PTY and some param; expect an 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"
CMD0="$SOCAT $opts /dev/null PTY:/tmp/xyz"
printf "test $F_n $TEST... " $N
$CMD0 >/dev/null 2>"${te}0"
rc0=$?
if [ $rc0 -ne 0 ]; then
$PRINTF "$OK\n"
numOK=$((numOK+1))
else
$PRINTF "$FAILED\n"
echo "$CMD0"
cat "${te}0"
numFAIL=$((numFAIL+1))
fi
fi # NUMCOND
;;
esac
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-pty.c */ /* source: xio-pty.c */
/* Copyright Gerhard Rieger 2002-2009 */ /* Copyright Gerhard Rieger 2002-2011 */
/* 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 creating pty addresses */ /* this file contains the source for creating pty addresses */
@ -47,6 +47,10 @@ static int xioopen_pty(int argc, const char *argv[], struct opt *opts, int xiofl
compatibility we choose "no" as default */ compatibility we choose "no" as default */
struct timespec pollintv = { PTY_INTERVALL }; struct timespec pollintv = { PTY_INTERVALL };
if (argc != 1) {
Error2("%s: wrong number of parameters (%d instead of 0)", argv[0], argc-1);
}
xfd->stream.howtoend = END_CLOSE; xfd->stream.howtoend = END_CLOSE;
if (applyopts_single(&xfd->stream, opts, PH_INIT) < 0) return -1; if (applyopts_single(&xfd->stream, opts, PH_INIT) < 0) return -1;