rebase nc(1) patch

This commit is contained in:
Brent Cook 2016-09-04 05:42:23 -05:00
parent 5bb829d86d
commit 93be612b5c

View File

@ -1,6 +1,6 @@
--- apps/nc/netcat.c.orig Thu Jul 7 07:25:23 2016
+++ apps/nc/netcat.c Thu Jul 7 07:25:37 2016
@@ -91,9 +91,13 @@
--- apps/nc/netcat.c.orig Sun Sep 4 05:37:35 2016
+++ apps/nc/netcat.c Sun Sep 4 05:40:24 2016
@@ -92,9 +92,13 @@
int Dflag; /* sodebug */
int Iflag; /* TCP receive buffer size */
int Oflag; /* TCP send buffer size */
@ -14,7 +14,7 @@
int usetls; /* use TLS */
char *Cflag; /* Public cert file */
@@ -145,7 +149,7 @@
@@ -146,7 +150,7 @@
struct servent *sv;
socklen_t len;
struct sockaddr_storage cliaddr;
@ -23,7 +23,7 @@
const char *errstr, *proxyhost = "", *proxyport = NULL;
struct addrinfo proxyhints;
char unix_dg_tmp_socket_buf[UNIX_DG_TMP_SOCKET_SIZE];
@@ -255,12 +259,14 @@
@@ -256,12 +260,14 @@
case 'u':
uflag = 1;
break;
@ -38,7 +38,7 @@
case 'v':
vflag = 1;
break;
@@ -293,9 +299,11 @@
@@ -294,9 +300,11 @@
errx(1, "TCP send window %s: %s",
errstr, optarg);
break;
@ -50,7 +50,7 @@
case 'T':
errstr = NULL;
errno = 0;
@@ -319,9 +327,11 @@
@@ -320,9 +328,11 @@
argc -= optind;
argv += optind;
@ -62,17 +62,17 @@
if (family == AF_UNIX) {
if (pledge("stdio rpath wpath cpath tmppath unix", NULL) == -1)
@@ -824,7 +834,10 @@
@@ -825,7 +835,10 @@
remote_connect(const char *host, const char *port, struct addrinfo hints)
{
struct addrinfo *res, *res0;
- int s, error, on = 1, save_errno;
+ int s, error, save_errno;
- int s = -1, error, on = 1, save_errno;
+ int s = -1, error, save_errno;
+#ifdef SO_BINDANY
+ int on = 1;
+#endif
if ((error = getaddrinfo(host, port, &hints, &res)))
if ((error = getaddrinfo(host, port, &hints, &res0)))
errx(1, "getaddrinfo: %s", gai_strerror(error));
@@ -839,8 +852,10 @@
if (sflag || pflag) {
@ -83,22 +83,22 @@
setsockopt(s, SOL_SOCKET, SO_BINDANY, &on, sizeof(on));
+#endif
memset(&ahints, 0, sizeof(struct addrinfo));
ahints.ai_family = res0->ai_family;
ahints.ai_family = res->ai_family;
ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM;
@@ -911,7 +926,10 @@
local_listen(char *host, char *port, struct addrinfo hints)
{
struct addrinfo *res, *res0;
- int s, ret, x = 1, save_errno;
+ int s, save_errno;
- int s = -1, ret, x = 1, save_errno;
+ int s = -1, save_errno;
+#ifdef SO_REUSEPORT
+ int ret, x = 1;
+#endif
int error;
/* Allow nodename to be null. */
@@ -933,9 +951,11 @@
res0->ai_protocol)) < 0)
@@ -932,9 +950,11 @@
res->ai_protocol)) < 0)
continue;
+#ifdef SO_REUSEPORT
@ -107,9 +107,9 @@
err(1, NULL);
+#endif
set_common_sockopts(s, res0->ai_family);
set_common_sockopts(s, res->ai_family);
@@ -1393,11 +1413,13 @@
@@ -1392,11 +1412,13 @@
{
int x = 1;
@ -123,7 +123,7 @@
if (Dflag) {
if (setsockopt(s, SOL_SOCKET, SO_DEBUG,
&x, sizeof(x)) == -1)
@@ -1434,13 +1456,17 @@
@@ -1433,13 +1455,17 @@
}
if (minttl != -1) {
@ -142,7 +142,7 @@
}
}
@@ -1597,14 +1623,22 @@
@@ -1596,14 +1622,22 @@
\t-P proxyuser\tUsername for proxy authentication\n\
\t-p port\t Specify local port for remote connects\n\
\t-R CAfile CA bundle\n\