rebased netcat patch

This commit is contained in:
Brent Cook 2019-10-27 09:28:56 -05:00
parent b8d4bf7922
commit f662008da6

View File

@ -1,5 +1,5 @@
--- apps/nc/netcat.c.orig Tue Mar 19 05:24:51 2019 --- apps/nc/netcat.c.orig Sun Oct 27 09:22:15 2019
+++ apps/nc/netcat.c Tue May 7 02:07:40 2019 +++ apps/nc/netcat.c Sun Oct 27 09:24:17 2019
@@ -93,9 +93,13 @@ @@ -93,9 +93,13 @@
int Dflag; /* sodebug */ int Dflag; /* sodebug */
int Iflag; /* TCP receive buffer size */ int Iflag; /* TCP receive buffer size */
@ -14,7 +14,7 @@
int usetls; /* use TLS */ int usetls; /* use TLS */
const char *Cflag; /* Public cert file */ const char *Cflag; /* Public cert file */
@@ -268,12 +272,14 @@ @@ -269,12 +273,14 @@
case 'u': case 'u':
uflag = 1; uflag = 1;
break; break;
@ -29,7 +29,7 @@
case 'v': case 'v':
vflag = 1; vflag = 1;
break; break;
@@ -320,9 +326,11 @@ @@ -321,9 +327,11 @@
case 'o': case 'o':
oflag = optarg; oflag = optarg;
break; break;
@ -41,7 +41,7 @@
case 'T': case 'T':
errstr = NULL; errstr = NULL;
errno = 0; errno = 0;
@@ -346,9 +354,11 @@ @@ -347,9 +355,11 @@
argc -= optind; argc -= optind;
argv += optind; argv += optind;
@ -53,19 +53,19 @@
/* Cruft to make sure options are clean, and used properly. */ /* Cruft to make sure options are clean, and used properly. */
if (argv[0] && !argv[1] && family == AF_UNIX) { if (argv[0] && !argv[1] && family == AF_UNIX) {
@@ -918,7 +928,10 @@ @@ -926,7 +936,10 @@
remote_connect(const char *host, const char *port, struct addrinfo hints) char *ipaddr)
{ {
struct addrinfo *res, *res0; struct addrinfo *res, *res0;
- int s = -1, error, on = 1, save_errno; - int s = -1, error, herr, on = 1, save_errno;
+ int s = -1, error, save_errno; + int s = -1, error, herr, save_errno;
+#ifdef SO_BINDANY +#ifdef SO_BINDANY
+ int on = 1; + int on = 1;
+#endif +#endif
if ((error = getaddrinfo(host, port, &hints, &res0))) if ((error = getaddrinfo(host, port, &hints, &res0)))
errx(1, "getaddrinfo for host \"%s\" port %s: %s", host, errx(1, "getaddrinfo for host \"%s\" port %s: %s", host,
@@ -933,8 +946,10 @@ @@ -941,8 +954,10 @@
if (sflag || pflag) { if (sflag || pflag) {
struct addrinfo ahints, *ares; struct addrinfo ahints, *ares;
@ -76,7 +76,7 @@
memset(&ahints, 0, sizeof(struct addrinfo)); memset(&ahints, 0, sizeof(struct addrinfo));
ahints.ai_family = res->ai_family; ahints.ai_family = res->ai_family;
ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM; ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM;
@@ -1005,7 +1020,10 @@ @@ -1028,7 +1043,10 @@
local_listen(const char *host, const char *port, struct addrinfo hints) local_listen(const char *host, const char *port, struct addrinfo hints)
{ {
struct addrinfo *res, *res0; struct addrinfo *res, *res0;
@ -88,8 +88,8 @@
int error; int error;
/* Allow nodename to be null. */ /* Allow nodename to be null. */
@@ -1026,9 +1044,11 @@ @@ -1049,9 +1067,11 @@
res->ai_protocol)) < 0) res->ai_protocol)) == -1)
continue; continue;
+#ifdef SO_REUSEPORT +#ifdef SO_REUSEPORT
@ -100,7 +100,7 @@
set_common_sockopts(s, res->ai_family); set_common_sockopts(s, res->ai_family);
@@ -1498,11 +1518,13 @@ @@ -1521,11 +1541,13 @@
{ {
int x = 1; int x = 1;
@ -114,7 +114,7 @@
if (Dflag) { if (Dflag) {
if (setsockopt(s, SOL_SOCKET, SO_DEBUG, if (setsockopt(s, SOL_SOCKET, SO_DEBUG,
&x, sizeof(x)) == -1) &x, sizeof(x)) == -1)
@@ -1513,9 +1535,16 @@ @@ -1536,9 +1558,16 @@
IP_TOS, &Tflag, sizeof(Tflag)) == -1) IP_TOS, &Tflag, sizeof(Tflag)) == -1)
err(1, "set IP ToS"); err(1, "set IP ToS");
@ -131,7 +131,7 @@
} }
if (Iflag) { if (Iflag) {
if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, if (setsockopt(s, SOL_SOCKET, SO_RCVBUF,
@@ -1539,13 +1568,17 @@ @@ -1562,13 +1591,17 @@
} }
if (minttl != -1) { if (minttl != -1) {
@ -150,7 +150,7 @@
} }
} }
@@ -1767,14 +1800,22 @@ @@ -1790,14 +1823,22 @@
\t-P proxyuser\tUsername for proxy authentication\n\ \t-P proxyuser\tUsername for proxy authentication\n\
\t-p port\t Specify local port for remote connects\n\ \t-p port\t Specify local port for remote connects\n\
\t-R CAfile CA bundle\n\ \t-R CAfile CA bundle\n\