aboutsummaryrefslogtreecommitdiff
path: root/patches/netcat.c.patch
diff options
context:
space:
mode:
authorBrent Cook <bcook@openbsd.org>2016-06-30 08:18:03 -0500
committerBrent Cook <bcook@openbsd.org>2016-06-30 08:18:03 -0500
commitec4c98718de35311541f3e5aca3a9c5e7101d62f (patch)
tree369ab3cc422ea93a85042e15c781a4a0ecbba193 /patches/netcat.c.patch
parent13b7ac8ada20b1d7f14321fb9fff311ebc860822 (diff)
downloadportable-ec4c98718de35311541f3e5aca3a9c5e7101d62f.tar.gz
portable-ec4c98718de35311541f3e5aca3a9c5e7101d62f.tar.bz2
portable-ec4c98718de35311541f3e5aca3a9c5e7101d62f.zip
refine netcat patch
Diffstat (limited to 'patches/netcat.c.patch')
-rw-r--r--patches/netcat.c.patch65
1 files changed, 29 insertions, 36 deletions
diff --git a/patches/netcat.c.patch b/patches/netcat.c.patch
index 71a1507..cf10de5 100644
--- a/patches/netcat.c.patch
+++ b/patches/netcat.c.patch
@@ -1,17 +1,6 @@
1--- apps/nc/netcat.c.orig Wed Jun 29 21:28:27 2016 1--- apps/nc/netcat.c.orig Wed Jun 29 21:28:27 2016
2+++ apps/nc/netcat.c Thu Jun 30 05:32:31 2016 2+++ apps/nc/netcat.c Thu Jun 30 08:16:42 2016
3@@ -57,6 +57,10 @@ 3@@ -65,7 +65,9 @@
4 #include <tls.h>
5 #include "atomicio.h"
6
7+#ifndef IPV6_TCLASS
8+#define IPV6_TCLASS -1
9+#endif
10+
11 #define PORT_MAX 65535
12 #define UNIX_DG_TMP_SOCKET_SIZE 19
13
14@@ -65,7 +69,9 @@
15 #define POLL_NETIN 2 4 #define POLL_NETIN 2
16 #define POLL_STDOUT 3 5 #define POLL_STDOUT 3
17 #define BUFSIZE 16384 6 #define BUFSIZE 16384
@@ -21,7 +10,7 @@
21 10
22 #define TLS_LEGACY (1 << 1) 11 #define TLS_LEGACY (1 << 1)
23 #define TLS_NOVERIFY (1 << 2) 12 #define TLS_NOVERIFY (1 << 2)
24@@ -92,9 +98,13 @@ 13@@ -92,9 +94,13 @@
25 int Dflag; /* sodebug */ 14 int Dflag; /* sodebug */
26 int Iflag; /* TCP receive buffer size */ 15 int Iflag; /* TCP receive buffer size */
27 int Oflag; /* TCP send buffer size */ 16 int Oflag; /* TCP send buffer size */
@@ -35,7 +24,7 @@
35 24
36 int usetls; /* use TLS */ 25 int usetls; /* use TLS */
37 char *Cflag; /* Public cert file */ 26 char *Cflag; /* Public cert file */
38@@ -152,7 +162,7 @@ 27@@ -152,7 +158,7 @@
39 struct servent *sv; 28 struct servent *sv;
40 socklen_t len; 29 socklen_t len;
41 struct sockaddr_storage cliaddr; 30 struct sockaddr_storage cliaddr;
@@ -44,7 +33,7 @@
44 const char *errstr, *proxyhost = "", *proxyport = NULL; 33 const char *errstr, *proxyhost = "", *proxyport = NULL;
45 struct addrinfo proxyhints; 34 struct addrinfo proxyhints;
46 char unix_dg_tmp_socket_buf[UNIX_DG_TMP_SOCKET_SIZE]; 35 char unix_dg_tmp_socket_buf[UNIX_DG_TMP_SOCKET_SIZE];
47@@ -262,12 +272,14 @@ 36@@ -262,12 +268,14 @@
48 case 'u': 37 case 'u':
49 uflag = 1; 38 uflag = 1;
50 break; 39 break;
@@ -59,7 +48,7 @@
59 case 'v': 48 case 'v':
60 vflag = 1; 49 vflag = 1;
61 break; 50 break;
62@@ -300,9 +312,11 @@ 51@@ -300,9 +308,11 @@
63 errx(1, "TCP send window %s: %s", 52 errx(1, "TCP send window %s: %s",
64 errstr, optarg); 53 errstr, optarg);
65 break; 54 break;
@@ -71,7 +60,7 @@
71 case 'T': 60 case 'T':
72 errstr = NULL; 61 errstr = NULL;
73 errno = 0; 62 errno = 0;
74@@ -326,9 +340,11 @@ 63@@ -326,9 +336,11 @@
75 argc -= optind; 64 argc -= optind;
76 argv += optind; 65 argv += optind;
77 66
@@ -83,7 +72,7 @@
83 72
84 if (family == AF_UNIX) { 73 if (family == AF_UNIX) {
85 if (pledge("stdio rpath wpath cpath tmppath unix", NULL) == -1) 74 if (pledge("stdio rpath wpath cpath tmppath unix", NULL) == -1)
86@@ -480,7 +496,10 @@ 75@@ -480,7 +492,10 @@
87 errx(1, "-H and -T noverify may not be used" 76 errx(1, "-H and -T noverify may not be used"
88 "together"); 77 "together");
89 tls_config_insecure_noverifycert(tls_cfg); 78 tls_config_insecure_noverifycert(tls_cfg);
@@ -95,7 +84,7 @@
95 } 84 }
96 if (lflag) { 85 if (lflag) {
97 struct tls *tls_cctx = NULL; 86 struct tls *tls_cctx = NULL;
98@@ -832,7 +851,10 @@ 87@@ -832,7 +847,10 @@
99 remote_connect(const char *host, const char *port, struct addrinfo hints) 88 remote_connect(const char *host, const char *port, struct addrinfo hints)
100 { 89 {
101 struct addrinfo *res, *res0; 90 struct addrinfo *res, *res0;
@@ -107,7 +96,7 @@
107 96
108 if ((error = getaddrinfo(host, port, &hints, &res))) 97 if ((error = getaddrinfo(host, port, &hints, &res)))
109 errx(1, "getaddrinfo: %s", gai_strerror(error)); 98 errx(1, "getaddrinfo: %s", gai_strerror(error));
110@@ -847,8 +869,10 @@ 99@@ -847,8 +865,10 @@
111 if (sflag || pflag) { 100 if (sflag || pflag) {
112 struct addrinfo ahints, *ares; 101 struct addrinfo ahints, *ares;
113 102
@@ -118,7 +107,7 @@
118 memset(&ahints, 0, sizeof(struct addrinfo)); 107 memset(&ahints, 0, sizeof(struct addrinfo));
119 ahints.ai_family = res0->ai_family; 108 ahints.ai_family = res0->ai_family;
120 ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM; 109 ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM;
121@@ -919,7 +943,10 @@ 110@@ -919,7 +939,10 @@
122 local_listen(char *host, char *port, struct addrinfo hints) 111 local_listen(char *host, char *port, struct addrinfo hints)
123 { 112 {
124 struct addrinfo *res, *res0; 113 struct addrinfo *res, *res0;
@@ -130,7 +119,7 @@
130 int error; 119 int error;
131 120
132 /* Allow nodename to be null. */ 121 /* Allow nodename to be null. */
133@@ -941,9 +968,11 @@ 122@@ -941,9 +964,11 @@
134 res0->ai_protocol)) < 0) 123 res0->ai_protocol)) < 0)
135 continue; 124 continue;
136 125
@@ -142,7 +131,7 @@
142 131
143 set_common_sockopts(s, res0->ai_family); 132 set_common_sockopts(s, res0->ai_family);
144 133
145@@ -1401,29 +1430,26 @@ 134@@ -1401,29 +1426,28 @@
146 { 135 {
147 int x = 1; 136 int x = 1;
148 137
@@ -174,13 +163,15 @@
174+ IP_TOS, &Tflag, sizeof(Tflag)) == -1) 163+ IP_TOS, &Tflag, sizeof(Tflag)) == -1)
175 err(1, "set IP ToS"); 164 err(1, "set IP ToS");
176+ 165+
177+ else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, 166+#ifdef IPV6_TCLASS
167+ if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6,
178+ IPV6_TCLASS, &Tflag, sizeof(Tflag)) == -1) 168+ IPV6_TCLASS, &Tflag, sizeof(Tflag)) == -1)
179+ err(1, "set IPv6 Traffic Class"); 169+ err(1, "set IPv6 traffic class");
170+#endif
180 } 171 }
181 if (Iflag) { 172 if (Iflag) {
182 if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, 173 if (setsockopt(s, SOL_SOCKET, SO_RCVBUF,
183@@ -1435,29 +1461,28 @@ 174@@ -1435,29 +1459,30 @@
184 &Oflag, sizeof(Oflag)) == -1) 175 &Oflag, sizeof(Oflag)) == -1)
185 err(1, "set TCP send buffer size"); 176 err(1, "set TCP send buffer size");
186 } 177 }
@@ -209,23 +200,25 @@
209+ 200+
210+ if (ttl != -1) { 201+ if (ttl != -1) {
211+ if (af == AF_INET && setsockopt(s, IPPROTO_IP, 202+ if (af == AF_INET && setsockopt(s, IPPROTO_IP,
212+ IP_TTL, &ttl, sizeof(ttl))) 203+ IP_TTL, &ttl, sizeof(ttl)))
213+ err(1, "setsockopt IP_TTL"); 204+ err(1, "set IP TTL");
214+ 205+
215+ else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, 206+ if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6,
216+ IPV6_UNICAST_HOPS, &ttl, sizeof(ttl))) 207+ IPV6_UNICAST_HOPS, &ttl, sizeof(ttl)))
217+ err(1, "setsockopt IPV6_UNICAST_HOPS"); 208+ err(1, "set IPv6 unicast hops");
218 } 209 }
219+ 210+
220+ if (minttl != -1) { 211+ if (minttl != -1) {
212+#ifdef IP_MINTTL
221+ if (af == AF_INET && setsockopt(s, IPPROTO_IP, 213+ if (af == AF_INET && setsockopt(s, IPPROTO_IP,
222+ IP_MINTTL, &minttl, sizeof(minttl))) 214+ IP_MINTTL, &minttl, sizeof(minttl)) == -1)
223+ err(1, "setsockopt IP_MINTTL"); 215+ err(1, "set IP min TTL");
216+#endif
224+ 217+
225+#ifdef IPV6_MINHOPCOUNT 218+#ifdef IPV6_MINHOPCOUNT
226+ else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, 219+ if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6,
227+ IPV6_MINHOPCOUNT, &minttl, sizeof(minttl))) 220+ IPV6_MINHOPCOUNT, &minttl, sizeof(minttl)) == -1)
228+ err(1, "setsockopt IPV6_MINHOPCOUNT"); 221+ err(1, "set IPv6 min hop count");
229+#endif 222+#endif
230+ } 223+ }
231 } 224 }