From owner-svn-src-all@FreeBSD.ORG Tue Oct 19 00:01:53 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D3ABD1065672; Tue, 19 Oct 2010 00:01:53 +0000 (UTC) (envelope-from delphij@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C09798FC0A; Tue, 19 Oct 2010 00:01:53 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9J01rj3091160; Tue, 19 Oct 2010 00:01:53 GMT (envelope-from delphij@svn.freebsd.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9J01raB091155; Tue, 19 Oct 2010 00:01:53 GMT (envelope-from delphij@svn.freebsd.org) Message-Id: <201010190001.o9J01raB091155@svn.freebsd.org> From: Xin LI Date: Tue, 19 Oct 2010 00:01:53 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214047 - in head: contrib/netcat usr.bin/nc X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 19 Oct 2010 00:01:53 -0000 Author: delphij Date: Tue Oct 19 00:01:53 2010 New Revision: 214047 URL: http://svn.freebsd.org/changeset/base/214047 Log: MFV: nc(1) from OpenBSD 4.8. While I'm there, bump WARNS level to 2 as the vendor have the right printf format string now. MFC after: 1 month Obtained from: OpenBSD Modified: head/contrib/netcat/nc.1 head/contrib/netcat/netcat.c head/contrib/netcat/socks.c head/usr.bin/nc/Makefile Directory Properties: head/contrib/netcat/ (props changed) Modified: head/contrib/netcat/nc.1 ============================================================================== --- head/contrib/netcat/nc.1 Mon Oct 18 23:37:56 2010 (r214046) +++ head/contrib/netcat/nc.1 Tue Oct 19 00:01:53 2010 (r214047) @@ -1,4 +1,4 @@ -.\" $OpenBSD: nc.1,v 1.53 2010/02/23 23:00:52 schwarze Exp $ +.\" $OpenBSD: nc.1,v 1.55 2010/07/25 07:51:39 guenther Exp $ .\" .\" Copyright (c) 1996 David Sacerdote .\" All rights reserved. @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 3, 2010 +.Dd July 25, 2010 .Dt NC 1 .Os .Sh NAME @@ -46,7 +46,7 @@ .Op Fl p Ar source_port .Op Fl s Ar source_ip_address .Op Fl T Ar ToS -.Op Fl V Ar fib +.Op Fl V Ar rtable .Op Fl w Ar timeout .Op Fl X Ar proxy_protocol .Oo Xo @@ -201,8 +201,10 @@ Specifies to use sockets. .It Fl u Use UDP instead of the default option of TCP. -.It Fl V Ar fib -Set the routing table (FIB). +.It Fl V Ar rtable +Set the routing table +.Pq Dq FIB +to be used. The default is 0. .It Fl v Have Modified: head/contrib/netcat/netcat.c ============================================================================== --- head/contrib/netcat/netcat.c Mon Oct 18 23:37:56 2010 (r214046) +++ head/contrib/netcat/netcat.c Tue Oct 19 00:01:53 2010 (r214047) @@ -1,4 +1,4 @@ -/* $OpenBSD: netcat.c,v 1.95 2010/02/27 00:58:56 nicm Exp $ */ +/* $OpenBSD: netcat.c,v 1.98 2010/07/03 04:44:51 guenther Exp $ */ /* * Copyright (c) 2001 Eric Jackson * @@ -93,7 +93,7 @@ int Iflag; /* TCP receive buffer siz int Oflag; /* TCP send buffer size */ int Sflag; /* TCP MD5 signature option */ int Tflag = -1; /* IP Type of Service */ -u_int rdomain; +u_int rtableid; int timeout = -1; int family = AF_UNSPEC; @@ -139,7 +139,6 @@ main(int argc, char *argv[]) { NULL, 0, NULL, 0 } }; - rdomain = 0; ret = 1; ipsec_count = 0; s = 0; @@ -235,10 +234,10 @@ main(int argc, char *argv[]) case 'V': if (sysctlbyname("net.fibs", &numfibs, &intsize, NULL, 0) == -1) errx(1, "Multiple FIBS not supported"); - rdomain = (unsigned int)strtonum(optarg, 0, + rtableid = (unsigned int)strtonum(optarg, 0, numfibs - 1, &errstr); if (errstr) - errx(1, "FIB %s: %s", errstr, optarg); + errx(1, "rtable %s: %s", errstr, optarg); break; case 'v': vflag = 1; @@ -371,11 +370,11 @@ main(int argc, char *argv[]) */ if (uflag) { int rv, plen; - char buf[8192]; + char buf[16384]; struct sockaddr_storage z; len = sizeof(z); - plen = jflag ? 8192 : 1024; + plen = jflag ? 16384 : 2048; rv = recvfrom(s, buf, plen, MSG_PEEK, (struct sockaddr *)&z, &len); if (rv < 0) @@ -561,8 +560,8 @@ remote_connect(const char *host, const c add_ipsec_policy(s, ipsec_policy[1]); #endif - if (rdomain) { - if (setfib(rdomain) == -1) + if (rtableid) { + if (setfib(rtableid) == -1) err(1, "setfib"); } @@ -634,8 +633,8 @@ local_listen(char *host, char *port, str res0->ai_protocol)) < 0) continue; - if (rdomain) { - if (setfib(rdomain) == -1) + if (rtableid) { + if (setfib(rtableid) == -1) err(1, "setfib"); } @@ -680,12 +679,12 @@ void readwrite(int nfd) { struct pollfd pfd[2]; - unsigned char buf[8192]; + unsigned char buf[16384]; int n, wfd = fileno(stdin); int lfd = fileno(stdout); int plen; - plen = jflag ? 8192 : 1024; + plen = jflag ? 16384 : 2048; /* Setup Network FD */ pfd[0].fd = nfd; @@ -827,10 +826,9 @@ build_ports(char *p) hi = strtonum(p, 1, PORT_MAX, &errstr); if (errstr) errx(1, "port number %s: %s", errstr, p); - portlist[0] = calloc(1, PORT_MAX_LEN); + portlist[0] = strdup(p); if (portlist[0] == NULL) err(1, NULL); - portlist[0] = p; } } @@ -947,7 +945,7 @@ help(void) \t-t Answer TELNET negotiation\n\ \t-U Use UNIX domain socket\n\ \t-u UDP mode\n\ - \t-V fib Specify alternate routing table (FIB)\n\ + \t-V rtable Specify alternate routing table\n\ \t-v Verbose\n\ \t-w secs\t Timeout for connects and final net reads\n\ \t-X proto Proxy protocol: \"4\", \"5\" (SOCKS) or \"connect\"\n\ @@ -992,7 +990,7 @@ usage(int ret) "usage: nc [-46DdhklnrStUuvz] [-I length] [-i interval] [-O length]\n" #endif "\t [-P proxy_username] [-p source_port] [-s source_ip_address] [-T ToS]\n" - "\t [-V fib] [-w timeout] [-X proxy_protocol]\n" + "\t [-V rtable] [-w timeout] [-X proxy_protocol]\n" "\t [-x proxy_address[:port]] [hostname] [port]\n"); if (ret) exit(1); Modified: head/contrib/netcat/socks.c ============================================================================== --- head/contrib/netcat/socks.c Mon Oct 18 23:37:56 2010 (r214046) +++ head/contrib/netcat/socks.c Tue Oct 19 00:01:53 2010 (r214047) @@ -1,4 +1,4 @@ -/* $OpenBSD: socks.c,v 1.17 2006/09/25 04:51:20 ray Exp $ */ +/* $OpenBSD: socks.c,v 1.18 2010/04/20 07:26:35 nicm Exp $ */ /* * Copyright (c) 1999 Niklas Hallqvist. All rights reserved. @@ -167,11 +167,11 @@ socks_connect(const char *host, const ch buf[2] = SOCKS_NOAUTH; cnt = atomicio(vwrite, proxyfd, buf, 3); if (cnt != 3) - err(1, "write failed (%d/3)", cnt); + err(1, "write failed (%zu/3)", cnt); cnt = atomicio(read, proxyfd, buf, 2); if (cnt != 2) - err(1, "read failed (%d/3)", cnt); + err(1, "read failed (%zu/3)", cnt); if (buf[1] == SOCKS_NOMETHOD) errx(1, "authentication method negotiation failed"); @@ -220,11 +220,11 @@ socks_connect(const char *host, const ch cnt = atomicio(vwrite, proxyfd, buf, wlen); if (cnt != wlen) - err(1, "write failed (%d/%d)", cnt, wlen); + err(1, "write failed (%zu/%zu)", cnt, wlen); cnt = atomicio(read, proxyfd, buf, 10); if (cnt != 10) - err(1, "read failed (%d/10)", cnt); + err(1, "read failed (%zu/10)", cnt); if (buf[1] != 0) errx(1, "connection failed, SOCKS error %d", buf[1]); } else if (socksv == 4) { @@ -242,11 +242,11 @@ socks_connect(const char *host, const ch cnt = atomicio(vwrite, proxyfd, buf, wlen); if (cnt != wlen) - err(1, "write failed (%d/%d)", cnt, wlen); + err(1, "write failed (%zu/%zu)", cnt, wlen); cnt = atomicio(read, proxyfd, buf, 8); if (cnt != 8) - err(1, "read failed (%d/8)", cnt); + err(1, "read failed (%zu/8)", cnt); if (buf[1] != 90) errx(1, "connection failed, SOCKS error %d", buf[1]); } else if (socksv == -1) { @@ -272,7 +272,7 @@ socks_connect(const char *host, const ch cnt = atomicio(vwrite, proxyfd, buf, r); if (cnt != r) - err(1, "write failed (%d/%d)", cnt, r); + err(1, "write failed (%zu/%d)", cnt, r); if (authretry > 1) { char resp[1024]; @@ -290,7 +290,7 @@ socks_connect(const char *host, const ch errx(1, "Proxy auth response too long"); r = strlen(buf); if ((cnt = atomicio(vwrite, proxyfd, buf, r)) != r) - err(1, "write failed (%d/%d)", cnt, r); + err(1, "write failed (%zu/%d)", cnt, r); } /* Terminate headers */ Modified: head/usr.bin/nc/Makefile ============================================================================== --- head/usr.bin/nc/Makefile Mon Oct 18 23:37:56 2010 (r214046) +++ head/usr.bin/nc/Makefile Tue Oct 19 00:01:53 2010 (r214047) @@ -9,6 +9,6 @@ CFLAGS+=-DIPSEC LDADD= -lipsec DPADD= ${LIBIPSEC} -WARNS?= 1 +WARNS?= 2 .include