mirror of
https://repo.or.cz/socat.git
synced 2024-12-22 23:42:34 +00:00
Option -R did not only dump right-to-left, but also left-to-right traffic
This commit is contained in:
parent
a390dfc547
commit
1a1cbb1598
3 changed files with 56 additions and 3 deletions
5
CHANGES
5
CHANGES
|
@ -35,6 +35,11 @@ Corrections:
|
||||||
Test: ABSTRACT_USER
|
Test: ABSTRACT_USER
|
||||||
Thanks to Andreas Fink for reporting this issue.
|
Thanks to Andreas Fink for reporting this issue.
|
||||||
|
|
||||||
|
Option -R did not only dump ("sniff") right-to-left, but also
|
||||||
|
left-to-right traffic to the given file.
|
||||||
|
Test: SNIFF_RIGHT_TO_LEFT
|
||||||
|
Thanks to 1314 gsf for reporting this bug and sending a patch.
|
||||||
|
|
||||||
Testing:
|
Testing:
|
||||||
Prevent the TIMESTAMP tests from sporadically failing due do seconds
|
Prevent the TIMESTAMP tests from sporadically failing due do seconds
|
||||||
overflow
|
overflow
|
||||||
|
|
4
socat.c
4
socat.c
|
@ -208,7 +208,7 @@ int main(int argc, const char *argv[]) {
|
||||||
O_LARGEFILE|
|
O_LARGEFILE|
|
||||||
#endif
|
#endif
|
||||||
O_NONBLOCK, 0664)) < 0)
|
O_NONBLOCK, 0664)) < 0)
|
||||||
Error2("option -r \"%s\": %s", a, strerror(errno));
|
Error2("option -R \"%s\": %s", a, strerror(errno));
|
||||||
break;
|
break;
|
||||||
case 'b': if (arg1[0][2]) {
|
case 'b': if (arg1[0][2]) {
|
||||||
a = *arg1+2;
|
a = *arg1+2;
|
||||||
|
@ -1303,7 +1303,7 @@ int xiotransfer(xiofile_t *inpipe, xiofile_t *outpipe,
|
||||||
|
|
||||||
if (!righttoleft && socat_opts.sniffleft >= 0) {
|
if (!righttoleft && socat_opts.sniffleft >= 0) {
|
||||||
Write(socat_opts.sniffleft, buff, bytes);
|
Write(socat_opts.sniffleft, buff, bytes);
|
||||||
} else if (socat_opts.sniffright >= 0) {
|
} else if (righttoleft && socat_opts.sniffright >= 0) {
|
||||||
Write(socat_opts.sniffright, buff, bytes);
|
Write(socat_opts.sniffright, buff, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
48
test.sh
48
test.sh
|
@ -15173,6 +15173,50 @@ PORT=$((PORT+1))
|
||||||
N=$((N+1))
|
N=$((N+1))
|
||||||
|
|
||||||
|
|
||||||
|
# Test if option -R does not "sniff" left-to-right traffic
|
||||||
|
NAME=SNIFF_RIGHT_TO_LEFT
|
||||||
|
case "$TESTS" in
|
||||||
|
*%$N%*|*%functions%*|*%bugs%*|*%$NAME%*)
|
||||||
|
TEST="$NAME: test if option -R does not "sniff" left-to-right traffic"
|
||||||
|
# Use option -R, check if left-to-right traffic is not in output file
|
||||||
|
if ! eval $NUMCOND; then :; else
|
||||||
|
tf="$td/test$N.stdout"
|
||||||
|
te="$td/test$N.stderr"
|
||||||
|
ts="$td/test$N.sniffed"
|
||||||
|
tdiff="$td/test$N.diff"
|
||||||
|
da="test$N $(date) $RANDOM"
|
||||||
|
CMD="$TRACE $SOCAT $opts -R $ts - /dev/null"
|
||||||
|
printf "test $F_n $TEST... " $N
|
||||||
|
echo "$da" |$CMD >"${tf}" 2>"${te}"
|
||||||
|
rc=$?
|
||||||
|
if [ ! -f "$ts" ]; then
|
||||||
|
$PRINTF "$CANT\n"
|
||||||
|
if [ "$VERBOSE" ]; then
|
||||||
|
echo "$CMD" >&2
|
||||||
|
cat "${te}" >&2
|
||||||
|
fi
|
||||||
|
numCANT=$((numCANT+1))
|
||||||
|
listCANT="$listCANT $N"
|
||||||
|
elif [ ! -s "$ts" ]; then
|
||||||
|
$PRINTF "$OK\n"
|
||||||
|
if [ "$VERBOSE" ]; then
|
||||||
|
echo "$CMD" >&2
|
||||||
|
fi
|
||||||
|
numOK=$((numOK+1))
|
||||||
|
else
|
||||||
|
$PRINTF "$FAILED\n"
|
||||||
|
echo "$CMD &" >&2
|
||||||
|
cat "${te}" >&2
|
||||||
|
numFAIL=$((numFAIL+1))
|
||||||
|
listFAIL="$listFAIL $N"
|
||||||
|
fi
|
||||||
|
fi # NUMCOND
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
PORT=$((PORT+1))
|
||||||
|
N=$((N+1))
|
||||||
|
|
||||||
|
|
||||||
# end of common tests
|
# end of common tests
|
||||||
|
|
||||||
##################################################################################
|
##################################################################################
|
||||||
|
@ -15296,11 +15340,15 @@ rc1=$?
|
||||||
kill $pid0 2>/dev/null; wait
|
kill $pid0 2>/dev/null; wait
|
||||||
if [ !!! ]; then
|
if [ !!! ]; then
|
||||||
$PRINTF "$OK\n"
|
$PRINTF "$OK\n"
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
if [" $VERBOSE" ]; then
|
if [" $VERBOSE" ]; then
|
||||||
=======
|
=======
|
||||||
if [ "$VERBOSE" ]; then
|
if [ "$VERBOSE" ]; then
|
||||||
>>>>>>> 8e56329... ABSTEACT-LISTEN with option user calls fchown()
|
>>>>>>> 8e56329... ABSTEACT-LISTEN with option user calls fchown()
|
||||||
|
=======
|
||||||
|
if [ "$VERBOSE" ]; then
|
||||||
|
>>>>>>> 4927d33... Option -R did not only dump right-to-left, but also left-to-right traffic
|
||||||
echo "$CMD0 &" >&2
|
echo "$CMD0 &" >&2
|
||||||
echo "$CMD1" >&2
|
echo "$CMD1" >&2
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue