diff options
author | Xin LI <delphij@FreeBSD.org> | 2010-03-23 22:56:19 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2010-03-23 22:56:19 +0000 |
commit | a83f96f1936ee3800ae6434d9099592cbbbbb930 (patch) | |
tree | 44455399512afb7278923d0499e5678e10da194f | |
parent | e49b9130151d620a48ea91a31305033222474e64 (diff) | |
download | src-test2-vendor/netcat/4.7.tar.gz src-test2-vendor/netcat/4.7.zip |
-rw-r--r-- | nc.1 | 16 | ||||
-rw-r--r-- | netcat.c | 32 |
2 files changed, 27 insertions, 21 deletions
@@ -1,4 +1,4 @@ -.\" $OpenBSD: nc.1,v 1.50 2009/06/05 06:47:12 jmc Exp $ +.\" $OpenBSD: nc.1,v 1.53 2010/02/23 23:00:52 schwarze Exp $ .\" .\" Copyright (c) 1996 David Sacerdote .\" All rights reserved. @@ -25,7 +25,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: June 5 2009 $ +.Dd $Mdocdate: February 23 2010 $ .Dt NC 1 .Os .Sh NAME @@ -47,8 +47,8 @@ .Op Fl X Ar proxy_protocol .Oo Xo .Fl x Ar proxy_address Ns Oo : Ns -.Ar port Oc Oc -.Xc +.Ar port Oc +.Xc Oc .Op Ar hostname .Op Ar port .Ek @@ -174,7 +174,9 @@ This makes it possible to use .Nm to script telnet sessions. .It Fl U -Specifies to use Unix Domain Sockets. +Specifies to use +.Ux Ns -domain +sockets. .It Fl u Use UDP instead of the default option of TCP. .It Fl V Ar rdomain @@ -386,7 +388,9 @@ IP for the local end of the connection: .Pp .Dl $ nc -s 10.1.2.3 host.example.com 42 .Pp -Create and listen on a Unix Domain Socket: +Create and listen on a +.Ux Ns -domain +socket: .Pp .Dl $ nc -lU /var/tmp/dsocket .Pp @@ -1,4 +1,4 @@ -/* $OpenBSD: netcat.c,v 1.93 2009/06/05 00:18:10 claudio Exp $ */ +/* $OpenBSD: netcat.c,v 1.95 2010/02/27 00:58:56 nicm Exp $ */ /* * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> * @@ -403,8 +403,10 @@ main(int argc, char *argv[]) uflag ? "udp" : "tcp"); } - printf("Connection to %s %s port [%s/%s] succeeded!\n", - host, portlist[i], uflag ? "udp" : "tcp", + fprintf(stderr, + "Connection to %s %s port [%s/%s] " + "succeeded!\n", host, portlist[i], + uflag ? "udp" : "tcp", sv ? sv->s_name : "*"); } if (!zflag) @@ -681,27 +683,27 @@ atelnet(int nfd, unsigned char *buf, unsigned int size) unsigned char *p, *end; unsigned char obuf[4]; - end = buf + size; - obuf[0] = '\0'; + if (size < 3) + return; + end = buf + size - 2; for (p = buf; p < end; p++) { if (*p != IAC) - break; + continue; obuf[0] = IAC; p++; if ((*p == WILL) || (*p == WONT)) obuf[1] = DONT; - if ((*p == DO) || (*p == DONT)) + else if ((*p == DO) || (*p == DONT)) obuf[1] = WONT; - if (obuf) { - p++; - obuf[2] = *p; - obuf[3] = '\0'; - if (atomicio(vwrite, nfd, obuf, 3) != 3) - warn("Write Error!"); - obuf[0] = '\0'; - } + else + continue; + + p++; + obuf[2] = *p; + if (atomicio(vwrite, nfd, obuf, 3) != 3) + warn("Write Error!"); } } |