diff options
author | delphij <delphij@FreeBSD.org> | 2007-03-28 01:55:49 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2007-03-28 01:55:49 +0000 |
commit | 2b70bf35871ed356480f16291b3bb440cf25a334 (patch) | |
tree | 29a18d3c0b145046f3ce2154781bf554affb6abd /contrib/netcat | |
parent | ae5f19e683f661b5fdb91368ed13625b8184eca7 (diff) | |
download | FreeBSD-src-2b70bf35871ed356480f16291b3bb440cf25a334.zip FreeBSD-src-2b70bf35871ed356480f16291b3bb440cf25a334.tar.gz |
Import netcat as of today's OPENBSD_4_1 snapshot.
Diffstat (limited to 'contrib/netcat')
-rw-r--r-- | contrib/netcat/nc.1 | 6 | ||||
-rw-r--r-- | contrib/netcat/netcat.c | 48 | ||||
-rw-r--r-- | contrib/netcat/socks.c | 5 |
3 files changed, 29 insertions, 30 deletions
diff --git a/contrib/netcat/nc.1 b/contrib/netcat/nc.1 index 852ded8..69fd5ed 100644 --- a/contrib/netcat/nc.1 +++ b/contrib/netcat/nc.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: nc.1,v 1.43 2006/01/31 09:34:12 jmc Exp $ +.\" $OpenBSD: nc.1,v 1.44 2006/12/02 01:08:30 jmc Exp $ .\" .\" Copyright (c) 1996 David Sacerdote .\" All rights reserved. @@ -319,8 +319,8 @@ As another example, an email may be submitted to an SMTP server using: .Bd -literal -offset indent $ nc localhost 25 \*(Lt\*(Lt EOF HELO host.example.com -MAIL FROM: \*(Ltuser@host.example.com\*(Gt -RCPT TO: \*(Ltuser2@host.example.com\*(Gt +MAIL FROM:\*(Ltuser@host.example.com\*(Gt +RCPT TO:\*(Ltuser2@host.example.com\*(Gt DATA Body of email. \&. diff --git a/contrib/netcat/netcat.c b/contrib/netcat/netcat.c index bea1b79..1c671f2 100644 --- a/contrib/netcat/netcat.c +++ b/contrib/netcat/netcat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: netcat.c,v 1.87 2006/02/01 21:33:14 otto Exp $ */ +/* $OpenBSD: netcat.c,v 1.89 2007/02/20 14:11:17 jmc Exp $ */ /* * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> * @@ -65,7 +65,7 @@ /* Command Line Options */ int dflag; /* detached, no stdin */ -int iflag; /* Interval Flag */ +unsigned int iflag; /* Interval Flag */ int jflag; /* use jumbo frames if we can */ int kflag; /* More than one connect */ int lflag; /* Bind to local port */ @@ -106,13 +106,13 @@ int main(int argc, char *argv[]) { int ch, s, ret, socksv; - char *host, *uport, *endp; + char *host, *uport; struct addrinfo hints; struct servent *sv; socklen_t len; struct sockaddr_storage cliaddr; char *proxy; - const char *proxyhost = "", *proxyport = NULL; + const char *errstr, *proxyhost = "", *proxyport = NULL; struct addrinfo proxyhints; ret = 1; @@ -120,7 +120,6 @@ main(int argc, char *argv[]) socksv = 5; host = NULL; uport = NULL; - endp = NULL; sv = NULL; while ((ch = getopt(argc, argv, @@ -152,9 +151,9 @@ main(int argc, char *argv[]) help(); break; case 'i': - iflag = (int)strtoul(optarg, &endp, 10); - if (iflag < 0 || *endp != '\0') - errx(1, "interval cannot be negative"); + iflag = strtonum(optarg, 0, UINT_MAX, &errstr); + if (errstr) + errx(1, "interval %s: %s", errstr, optarg); break; case 'j': jflag = 1; @@ -190,11 +189,9 @@ main(int argc, char *argv[]) vflag = 1; break; case 'w': - timeout = (int)strtoul(optarg, &endp, 10); - if (timeout < 0 || *endp != '\0') - errx(1, "timeout cannot be negative"); - if (timeout >= (INT_MAX / 1000)) - errx(1, "timeout too large"); + timeout = strtonum(optarg, 0, INT_MAX / 1000, &errstr); + if (errstr) + errx(1, "timeout %s: %s", errstr, optarg); timeout *= 1000; break; case 'x': @@ -681,7 +678,8 @@ atelnet(int nfd, unsigned char *buf, unsigned int size) void build_ports(char *p) { - char *n, *endp; + const char *errstr; + char *n; int hi, lo, cp; int x = 0; @@ -693,12 +691,12 @@ build_ports(char *p) n++; /* Make sure the ports are in order: lowest->highest. */ - hi = (int)strtoul(n, &endp, 10); - if (hi <= 0 || hi > PORT_MAX || *endp != '\0') - errx(1, "port range not valid"); - lo = (int)strtoul(p, &endp, 10); - if (lo <= 0 || lo > PORT_MAX || *endp != '\0') - errx(1, "port range not valid"); + hi = strtonum(n, 1, PORT_MAX, &errstr); + if (errstr) + errx(1, "port number %s: %s", errstr, n); + lo = strtonum(p, 1, PORT_MAX, &errstr); + if (errstr) + errx(1, "port number %s: %s", errstr, p); if (lo > hi) { cp = hi; @@ -728,9 +726,9 @@ build_ports(char *p) } } } else { - hi = (int)strtoul(p, &endp, 10); - if (hi <= 0 || hi > PORT_MAX || *endp != '\0') - errx(1, "port range not valid"); + hi = strtonum(p, 1, PORT_MAX, &errstr); + if (errstr) + errx(1, "port number %s: %s", errstr, p); portlist[0] = calloc(1, PORT_MAX_LEN); if (portlist[0] == NULL) err(1, NULL); @@ -837,8 +835,8 @@ help(void) void usage(int ret) { - fprintf(stderr, "usage: nc [-46DdhklnrStUuvz] [-i interval] [-p source_port]\n"); - fprintf(stderr, "\t [-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_version]\n"); + fprintf(stderr, "usage: nc [-46DdhklnrStUuvz] [-i interval] [-P proxy_username] [-p source_port]\n"); + fprintf(stderr, "\t [-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_protocol]\n"); fprintf(stderr, "\t [-x proxy_address[:port]] [hostname] [port[s]]\n"); if (ret) exit(1); diff --git a/contrib/netcat/socks.c b/contrib/netcat/socks.c index daed997..da7bd0c 100644 --- a/contrib/netcat/socks.c +++ b/contrib/netcat/socks.c @@ -1,4 +1,4 @@ -/* $OpenBSD: socks.c,v 1.16 2006/01/25 23:21:37 djm Exp $ */ +/* $OpenBSD: socks.c,v 1.17 2006/09/25 04:51:20 ray Exp $ */ /* * Copyright (c) 1999 Niklas Hallqvist. All rights reserved. @@ -307,7 +307,8 @@ socks_connect(const char *host, const char *port, } close(proxyfd); goto again; - } else if (strncmp(buf, "HTTP/1.0 200 ", 12) != 0) + } else if (strncmp(buf, "HTTP/1.0 200 ", 12) != 0 && + strncmp(buf, "HTTP/1.1 200 ", 12) != 0) errx(1, "Proxy error: \"%s\"", buf); /* Headers continue until we hit an empty line */ |