From owner-svn-src-head@FreeBSD.ORG Sat Oct 25 00:37:36 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 32612E64; Sat, 25 Oct 2014 00:37:36 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 04C735FB; Sat, 25 Oct 2014 00:37:36 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9P0bZBv048108; Sat, 25 Oct 2014 00:37:35 GMT (envelope-from delphij@FreeBSD.org) Received: (from delphij@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9P0bZUo048107; Sat, 25 Oct 2014 00:37:35 GMT (envelope-from delphij@FreeBSD.org) Message-Id: <201410250037.s9P0bZUo048107@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: delphij set sender to delphij@FreeBSD.org using -f From: Xin LI Date: Sat, 25 Oct 2014 00:37:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273619 - head/contrib/netcat X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 25 Oct 2014 00:37:36 -0000 Author: delphij Date: Sat Oct 25 00:37:35 2014 New Revision: 273619 URL: https://svnweb.freebsd.org/changeset/base/273619 Log: MFV r273617: netcat from OpenBSD 5.6. MFC after: 2 weeks Modified: head/contrib/netcat/netcat.c Directory Properties: head/contrib/netcat/ (props changed) Modified: head/contrib/netcat/netcat.c ============================================================================== --- head/contrib/netcat/netcat.c Sat Oct 25 00:32:30 2014 (r273618) +++ head/contrib/netcat/netcat.c Sat Oct 25 00:37:35 2014 (r273619) @@ -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 * @@ -155,9 +155,6 @@ main(int argc, char *argv[]) host = NULL; uport = NULL; sv = NULL; -#if 0 - rtableid = getrtable(); -#endif while ((ch = getopt_long(argc, argv, "46DdEe:FhI:i:klNnoO:P:p:rSs:tT:UuV:vw:X:x:z", @@ -662,7 +659,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); } @@ -751,7 +748,7 @@ local_listen(char *host, char *port, str res0->ai_protocol)) < 0) continue; - if (rtableid >= 0 && (setsockopt(s, IPPROTO_IP, SO_SETFIB, + if (rtableid >= 0 && (setsockopt(s, SOL_SOCKET, SO_SETFIB, &rtableid, sizeof(rtableid)) == -1)) err(1, "setsockopt SO_SETFIB"); @@ -796,12 +793,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; @@ -816,8 +813,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)