X-Git-Url: https://git.distorted.org.uk/~mdw/userv-utils/blobdiff_plain/abe75cda09856fedab1d54cc04e0c49b95ece805..6aaa2ce375024c33559abf60ca3c72a923b112ba:/ipif/udptunnel diff --git a/ipif/udptunnel b/ipif/udptunnel index 7c977e1..1b5031c 100755 --- a/ipif/udptunnel +++ b/ipif/udptunnel @@ -215,7 +215,7 @@ for (;;) { quit "tunnel endpoint closed by system"; } while (($p= index($upbuf,"\300")) >= 0) { - if (!defined(send L,substr($upbuf,0,$p+1),0,$rs)) { + if ($p && !defined(send L,substr($upbuf,0,$p),0,$rs)) { warning("transmit error: $!"); } else { if (!$upyet) { @@ -233,6 +233,7 @@ for (;;) { warning("got packet from incorrect peer $rsp_from"); next; } + $downbuf= "\300".$downbuf."\300"; if (!defined($r= syswrite(DW,$downbuf,length $downbuf))) { warning("tunnel endpoint write error: $!"); } elsif ($r != length $downbuf) { @@ -245,5 +246,6 @@ for (;;) { alarm($timeout) if $timeout; } } + if ($! == ECONNREFUSED) { quit("tunnel closed at remote end"); } $! == EAGAIN || warning("receive error: $!"); }