1
0
mirror of https://github.com/moparisthebest/socat synced 2024-12-21 22:48:48 -05:00

EXEC address with consecutive spaces created additional empty arguments

This commit is contained in:
Gerhard Rieger 2008-07-17 21:49:52 +02:00
parent ad4bd0d9db
commit ae368e7cb9
4 changed files with 41 additions and 2 deletions

View File

@ -12,6 +12,10 @@ corrections:
EXEC and SYSTEM with stderr injected socat messages into the data
stream. test: EXECSTDERRLOG
when the EXEC address got a string with consecutive spaces it created
additional empty arguments (thanks to Olivier Hervieu for reporting
this bug)
####################### V 1.6.0.1:
new features:

View File

@ -1 +1 @@
"1.6.0.1+ip4bind+recvfromfork+x64+execstderr"
"1.6.0.1+ip4bind+recvfromfork+x64+execstderr+execspaces"

35
test.sh
View File

@ -8261,6 +8261,41 @@ PORT=$((PORT+1))
N=$((N+1))
# there was a bug in parsing the arguments of exec: consecutive spaces resulted
# in additional empty arguments
NAME=EXECSPACES
case "$TESTS" in
*%functions%*|*%exec%*|*%parse%*|*%$NAME%*)
TEST="$NAME: correctly parse exec with consecutive spaces"
$PRINTF "test $F_n $TEST... " $N
tf="$td/test$N.stdout"
te="$td/test$N.stderr"
da="test$N $(date) $RANDOM"
tdiff="$td/test$N.diff"
# put the test data as first argument after two spaces. expect the data in the
# first argument of the exec'd command.
$SOCAT $opts -u "exec:\"bash -c \\\"echo \$1\\\" \\\"\\\" \\\"$da\\\"\"" - >"$tf" 2>"$te"
rc=$?
echo "$da" |diff - "$tf" >"$tdiff"
if [ "$rc" -ne 0 ]; then
$PRINTF "$FAILED: $SOCAT:\n"
cat "$te"
numFAIL=$((numFAIL+1))
elif [ -s "$tdiff" ]; then
$PRINTF "$FAILED: $SOCAT:\n"
echo diff:
cat "$tdiff"
if [ -n "$debug" ]; then cat $te; fi
numFAIL=$((numFAIL+1))
else
$PRINTF "$OK\n"
if [ -n "$debug" ]; then cat $te; fi
numOK=$((numOK+1))
fi
esac
N=$((N+1))
echo "summary: $((N-1)) tests; $numOK ok, $numFAIL failed, $numCANT could not be performed"
if [ "$numFAIL" -gt 0 ]; then

View File

@ -83,11 +83,11 @@ static int xioopen_exec(int argc, const char *argv[], struct opt *opts,
if (pargv[0] == NULL) pargv[0] = token; else ++pargv[0];
pargc = 1;
while (*strp == ' ') {
while (*++strp == ' ') ;
if ((pargc & 0x07) == 0) {
pargv = Realloc(pargv, (pargc+8)*sizeof(char *));
if (pargv == NULL) return STAT_RETRYLATER;
}
++strp;
pargv[pargc++] = tokp;
if (nestlex(&strp, &tokp, &len, ends, hquotes, squotes, nests,
true, true, false) < 0) {