From b8d16ecd516ae44649f0d8961c85f2140141c0c3 Mon Sep 17 00:00:00 2001 From: Gerhard Rieger Date: Thu, 10 Mar 2011 07:55:03 +0100 Subject: [PATCH] issue error when PTY called with parameters --- CHANGES | 3 +++ test.sh | 32 +++++++++++++++++++++++++++++++- xio-pty.c | 6 +++++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 4e1f09e..2a12aba 100644 --- a/CHANGES +++ b/CHANGES @@ -23,6 +23,9 @@ corrections: socat option -x did not print packet direction, timestamp etc; thanks 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: security: diff --git a/test.sh b/test.sh index be422b3..68dc452 100755 --- a/test.sh +++ b/test.sh @@ -1,6 +1,6 @@ #! /bin/bash # 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 # perform lots of tests on socat @@ -10409,6 +10409,36 @@ esac 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 # before this paragraph. diff --git a/xio-pty.c b/xio-pty.c index c478d7c..dff08a5 100644 --- a/xio-pty.c +++ b/xio-pty.c @@ -1,5 +1,5 @@ /* 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 */ /* 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 */ 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; if (applyopts_single(&xfd->stream, opts, PH_INIT) < 0) return -1;