summaryrefslogtreecommitdiffstats
path: root/contrib/netcat
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2010-03-23 23:00:35 +0000
committerdelphij <delphij@FreeBSD.org>2010-03-23 23:00:35 +0000
commit7f20b83b68f6e0cfd7a0c361f8c92190950f66ea (patch)
tree50d671b217d7a98ea400b69a1c596bc5b38db835 /contrib/netcat
parent5440f52b56b7ceb4a1d86d48b41b5690c5b8ed30 (diff)
downloadFreeBSD-src-7f20b83b68f6e0cfd7a0c361f8c92190950f66ea.zip
FreeBSD-src-7f20b83b68f6e0cfd7a0c361f8c92190950f66ea.tar.gz
MFV: Update nc to the version from OpenBSD 4.7.
MFC after: 1 month
Diffstat (limited to 'contrib/netcat')
-rw-r--r--contrib/netcat/nc.116
-rw-r--r--contrib/netcat/netcat.c32
2 files changed, 27 insertions, 21 deletions
diff --git a/contrib/netcat/nc.1 b/contrib/netcat/nc.1
index 4375ae8..fc2c8af 100644
--- a/contrib/netcat/nc.1
+++ b/contrib/netcat/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.
@@ -27,7 +27,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd June 5 2009
+.Dd February 23, 2010
.Dt NC 1
.Os
.Sh NAME
@@ -51,8 +51,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
@@ -206,7 +206,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 fib
@@ -428,7 +430,9 @@ outgoing traffic only.
.Pp
.Dl $ nc -e 'out ipsec esp/transport//require' 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/contrib/netcat/netcat.c b/contrib/netcat/netcat.c
index a9ce18b..c83f622 100644
--- a/contrib/netcat/netcat.c
+++ b/contrib/netcat/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>
*
@@ -455,8 +455,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)
@@ -749,27 +751,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!");
}
}
OpenPOWER on IntegriCloud