aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXin LI <delphij@FreeBSD.org>2010-03-23 22:56:19 +0000
committerXin LI <delphij@FreeBSD.org>2010-03-23 22:56:19 +0000
commita83f96f1936ee3800ae6434d9099592cbbbbb930 (patch)
tree44455399512afb7278923d0499e5678e10da194f
parente49b9130151d620a48ea91a31305033222474e64 (diff)
downloadsrc-a83f96f1936ee3800ae6434d9099592cbbbbb930.tar.gz
src-a83f96f1936ee3800ae6434d9099592cbbbbb930.zip
Import nc from OpenBSD's OPENBSD_4_7 as of today.vendor/netcat/4.7
Notes
Notes: svn path=/vendor/netcat/dist/; revision=205559 svn path=/vendor/netcat/4.7/; revision=205560; tag=vendor/netcat/4.7
-rw-r--r--nc.116
-rw-r--r--netcat.c32
2 files changed, 27 insertions, 21 deletions
diff --git a/nc.1 b/nc.1
index 68c90d767d11..94a2d43cdbbe 100644
--- a/nc.1
+++ b/nc.1
@@ -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
diff --git a/netcat.c b/netcat.c
index 6700f89cfe5b..508712388dfd 100644
--- a/netcat.c
+++ b/netcat.c
@@ -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!");
}
}