Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Oct 2014 00:32:06 +0000 (UTC)
From:      Xin LI <delphij@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org
Subject:   svn commit: r273617 - vendor/netcat/dist
Message-ID:  <201410250032.s9P0W6gu047323@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: delphij
Date: Sat Oct 25 00:32:05 2014
New Revision: 273617
URL: https://svnweb.freebsd.org/changeset/base/273617

Log:
  Vendor import nc(1) from OPENBSD_5_6.

Modified:
  vendor/netcat/dist/netcat.c

Modified: vendor/netcat/dist/netcat.c
==============================================================================
--- vendor/netcat/dist/netcat.c	Sat Oct 25 00:16:36 2014	(r273616)
+++ vendor/netcat/dist/netcat.c	Sat Oct 25 00:32:05 2014	(r273617)
@@ -1,4 +1,4 @@
-/* $OpenBSD: netcat.c,v 1.117 2013/10/26 21:33:29 sthen Exp $ */
+/* $OpenBSD: netcat.c,v 1.122 2014/07/20 01:38:40 guenther Exp $ */
 /*
  * Copyright (c) 2001 Eric Jackson <ericj@monkey.org>
  *
@@ -133,7 +133,6 @@ main(int argc, char *argv[])
 	host = NULL;
 	uport = NULL;
 	sv = NULL;
-	rtableid = getrtable();
 
 	while ((ch = getopt(argc, argv,
 	    "46DdFhI:i:klNnO:P:p:rSs:tT:UuV:vw:X:x:z")) != -1) {
@@ -609,7 +608,7 @@ remote_connect(const char *host, const c
 
 			if (bind(s, (struct sockaddr *)ares->ai_addr,
 			    ares->ai_addrlen) < 0)
-				errx(1, "bind failed: %s", strerror(errno));
+				err(1, "bind failed");
 			freeaddrinfo(ares);
 		}
 
@@ -698,7 +697,7 @@ local_listen(char *host, char *port, str
 		    res0->ai_protocol)) < 0)
 			continue;
 
-		if (rtableid >= 0 && (setsockopt(s, IPPROTO_IP, SO_RTABLE,
+		if (rtableid >= 0 && (setsockopt(s, SOL_SOCKET, SO_RTABLE,
 		    &rtableid, sizeof(rtableid)) == -1))
 			err(1, "setsockopt SO_RTABLE");
 
@@ -734,12 +733,12 @@ void
 readwrite(int nfd)
 {
 	struct pollfd pfd[2];
-	unsigned char buf[16384];
+	unsigned char buf[16 * 1024];
 	int n, wfd = fileno(stdin);
 	int lfd = fileno(stdout);
 	int plen;
 
-	plen = 2048;
+	plen = sizeof(buf);
 
 	/* Setup Network FD */
 	pfd[0].fd = nfd;
@@ -754,8 +753,9 @@ readwrite(int nfd)
 			sleep(iflag);
 
 		if ((n = poll(pfd, 2 - dflag, timeout)) < 0) {
+			int saved_errno = errno;
 			close(nfd);
-			err(1, "Polling Error");
+			errc(1, saved_errno, "Polling Error");
 		}
 
 		if (n == 0)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201410250032.s9P0W6gu047323>