diff options
author | Brent Cook <bcook@openbsd.org> | 2016-06-30 05:49:38 -0500 |
---|---|---|
committer | Brent Cook <bcook@openbsd.org> | 2016-06-30 05:49:38 -0500 |
commit | 13b7ac8ada20b1d7f14321fb9fff311ebc860822 (patch) | |
tree | 6dd6f2297d8e86cc67fbcdaf1e3c1e78564d9be0 /patches/netcat.c.patch | |
parent | ddb22413ed761294b04365b20eae1f6667372cf6 (diff) | |
download | portable-13b7ac8ada20b1d7f14321fb9fff311ebc860822.tar.gz portable-13b7ac8ada20b1d7f14321fb9fff311ebc860822.tar.bz2 portable-13b7ac8ada20b1d7f14321fb9fff311ebc860822.zip |
update netcat patch
Diffstat (limited to 'patches/netcat.c.patch')
-rw-r--r-- | patches/netcat.c.patch | 109 |
1 files changed, 92 insertions, 17 deletions
diff --git a/patches/netcat.c.patch b/patches/netcat.c.patch index 16f1388..71a1507 100644 --- a/patches/netcat.c.patch +++ b/patches/netcat.c.patch | |||
@@ -1,5 +1,5 @@ | |||
1 | --- apps/nc/netcat.c.orig Mon May 30 11:05:31 2016 | 1 | --- apps/nc/netcat.c.orig Wed Jun 29 21:28:27 2016 |
2 | +++ apps/nc/netcat.c Mon May 30 11:05:44 2016 | 2 | +++ apps/nc/netcat.c Thu Jun 30 05:32:31 2016 |
3 | @@ -57,6 +57,10 @@ | 3 | @@ -57,6 +57,10 @@ |
4 | #include <tls.h> | 4 | #include <tls.h> |
5 | #include "atomicio.h" | 5 | #include "atomicio.h" |
@@ -35,7 +35,7 @@ | |||
35 | 35 | ||
36 | int usetls; /* use TLS */ | 36 | int usetls; /* use TLS */ |
37 | char *Cflag; /* Public cert file */ | 37 | char *Cflag; /* Public cert file */ |
38 | @@ -150,7 +160,7 @@ | 38 | @@ -152,7 +162,7 @@ |
39 | struct servent *sv; | 39 | struct servent *sv; |
40 | socklen_t len; | 40 | socklen_t len; |
41 | struct sockaddr_storage cliaddr; | 41 | struct sockaddr_storage cliaddr; |
@@ -44,7 +44,7 @@ | |||
44 | const char *errstr, *proxyhost = "", *proxyport = NULL; | 44 | const char *errstr, *proxyhost = "", *proxyport = NULL; |
45 | struct addrinfo proxyhints; | 45 | struct addrinfo proxyhints; |
46 | char unix_dg_tmp_socket_buf[UNIX_DG_TMP_SOCKET_SIZE]; | 46 | char unix_dg_tmp_socket_buf[UNIX_DG_TMP_SOCKET_SIZE]; |
47 | @@ -251,12 +261,14 @@ | 47 | @@ -262,12 +272,14 @@ |
48 | case 'u': | 48 | case 'u': |
49 | uflag = 1; | 49 | uflag = 1; |
50 | break; | 50 | break; |
@@ -59,7 +59,7 @@ | |||
59 | case 'v': | 59 | case 'v': |
60 | vflag = 1; | 60 | vflag = 1; |
61 | break; | 61 | break; |
62 | @@ -289,9 +301,11 @@ | 62 | @@ -300,9 +312,11 @@ |
63 | errx(1, "TCP send window %s: %s", | 63 | errx(1, "TCP send window %s: %s", |
64 | errstr, optarg); | 64 | errstr, optarg); |
65 | break; | 65 | break; |
@@ -71,7 +71,7 @@ | |||
71 | case 'T': | 71 | case 'T': |
72 | errstr = NULL; | 72 | errstr = NULL; |
73 | errno = 0; | 73 | errno = 0; |
74 | @@ -315,9 +329,11 @@ | 74 | @@ -326,9 +340,11 @@ |
75 | argc -= optind; | 75 | argc -= optind; |
76 | argv += optind; | 76 | argv += optind; |
77 | 77 | ||
@@ -83,7 +83,7 @@ | |||
83 | 83 | ||
84 | if (family == AF_UNIX) { | 84 | if (family == AF_UNIX) { |
85 | if (pledge("stdio rpath wpath cpath tmppath unix", NULL) == -1) | 85 | if (pledge("stdio rpath wpath cpath tmppath unix", NULL) == -1) |
86 | @@ -469,7 +485,10 @@ | 86 | @@ -480,7 +496,10 @@ |
87 | errx(1, "-H and -T noverify may not be used" | 87 | errx(1, "-H and -T noverify may not be used" |
88 | "together"); | 88 | "together"); |
89 | tls_config_insecure_noverifycert(tls_cfg); | 89 | tls_config_insecure_noverifycert(tls_cfg); |
@@ -95,19 +95,19 @@ | |||
95 | } | 95 | } |
96 | if (lflag) { | 96 | if (lflag) { |
97 | struct tls *tls_cctx = NULL; | 97 | struct tls *tls_cctx = NULL; |
98 | @@ -817,7 +836,10 @@ | 98 | @@ -832,7 +851,10 @@ |
99 | remote_connect(const char *host, const char *port, struct addrinfo hints) | 99 | remote_connect(const char *host, const char *port, struct addrinfo hints) |
100 | { | 100 | { |
101 | struct addrinfo *res, *res0; | 101 | struct addrinfo *res, *res0; |
102 | - int s, error, on = 1; | 102 | - int s, error, on = 1, save_errno; |
103 | + int s, error; | 103 | + int s, error, save_errno; |
104 | +#ifdef SO_BINDANY | 104 | +#ifdef SO_BINDANY |
105 | + int on = 1; | 105 | + int on = 1; |
106 | +#endif | 106 | +#endif |
107 | 107 | ||
108 | if ((error = getaddrinfo(host, port, &hints, &res))) | 108 | if ((error = getaddrinfo(host, port, &hints, &res))) |
109 | errx(1, "getaddrinfo: %s", gai_strerror(error)); | 109 | errx(1, "getaddrinfo: %s", gai_strerror(error)); |
110 | @@ -832,8 +854,10 @@ | 110 | @@ -847,8 +869,10 @@ |
111 | if (sflag || pflag) { | 111 | if (sflag || pflag) { |
112 | struct addrinfo ahints, *ares; | 112 | struct addrinfo ahints, *ares; |
113 | 113 | ||
@@ -118,19 +118,19 @@ | |||
118 | memset(&ahints, 0, sizeof(struct addrinfo)); | 118 | memset(&ahints, 0, sizeof(struct addrinfo)); |
119 | ahints.ai_family = res0->ai_family; | 119 | ahints.ai_family = res0->ai_family; |
120 | ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM; | 120 | ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM; |
121 | @@ -902,7 +926,10 @@ | 121 | @@ -919,7 +943,10 @@ |
122 | local_listen(char *host, char *port, struct addrinfo hints) | 122 | local_listen(char *host, char *port, struct addrinfo hints) |
123 | { | 123 | { |
124 | struct addrinfo *res, *res0; | 124 | struct addrinfo *res, *res0; |
125 | - int s, ret, x = 1; | 125 | - int s, ret, x = 1, save_errno; |
126 | + int s; | 126 | + int s, save_errno; |
127 | +#ifdef SO_REUSEPORT | 127 | +#ifdef SO_REUSEPORT |
128 | + int ret, x = 1; | 128 | + int ret, x = 1; |
129 | +#endif | 129 | +#endif |
130 | int error; | 130 | int error; |
131 | 131 | ||
132 | /* Allow nodename to be null. */ | 132 | /* Allow nodename to be null. */ |
133 | @@ -924,9 +951,11 @@ | 133 | @@ -941,9 +968,11 @@ |
134 | res0->ai_protocol)) < 0) | 134 | res0->ai_protocol)) < 0) |
135 | continue; | 135 | continue; |
136 | 136 | ||
@@ -142,7 +142,7 @@ | |||
142 | 142 | ||
143 | set_common_sockopts(s, res0->ai_family); | 143 | set_common_sockopts(s, res0->ai_family); |
144 | 144 | ||
145 | @@ -1366,11 +1395,13 @@ | 145 | @@ -1401,29 +1430,26 @@ |
146 | { | 146 | { |
147 | int x = 1; | 147 | int x = 1; |
148 | 148 | ||
@@ -156,7 +156,82 @@ | |||
156 | if (Dflag) { | 156 | if (Dflag) { |
157 | if (setsockopt(s, SOL_SOCKET, SO_DEBUG, | 157 | if (setsockopt(s, SOL_SOCKET, SO_DEBUG, |
158 | &x, sizeof(x)) == -1) | 158 | &x, sizeof(x)) == -1) |
159 | @@ -1553,14 +1584,22 @@ | 159 | err(1, NULL); |
160 | } | ||
161 | if (Tflag != -1) { | ||
162 | - int proto, option; | ||
163 | - | ||
164 | - if (af == AF_INET6) { | ||
165 | - proto = IPPROTO_IPV6; | ||
166 | - option = IPV6_TCLASS; | ||
167 | - } else { | ||
168 | - proto = IPPROTO_IP; | ||
169 | - option = IP_TOS; | ||
170 | - } | ||
171 | - | ||
172 | - if (setsockopt(s, proto, option, &Tflag, sizeof(Tflag)) == -1) | ||
173 | + if (af == AF_INET && setsockopt(s, IPPROTO_IP, | ||
174 | + IP_TOS, &Tflag, sizeof(Tflag)) == -1) | ||
175 | err(1, "set IP ToS"); | ||
176 | + | ||
177 | + else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, | ||
178 | + IPV6_TCLASS, &Tflag, sizeof(Tflag)) == -1) | ||
179 | + err(1, "set IPv6 Traffic Class"); | ||
180 | } | ||
181 | if (Iflag) { | ||
182 | if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, | ||
183 | @@ -1435,29 +1461,28 @@ | ||
184 | &Oflag, sizeof(Oflag)) == -1) | ||
185 | err(1, "set TCP send buffer size"); | ||
186 | } | ||
187 | - if (ttl != -1 || minttl != -1) { | ||
188 | - int proto, in_ttl_opt, out_ttl_opt; | ||
189 | - switch (af) { | ||
190 | - case AF_INET: | ||
191 | - proto = IPPROTO_IP; | ||
192 | - in_ttl_opt = IP_MINTTL; | ||
193 | - out_ttl_opt = IP_TTL; | ||
194 | - break; | ||
195 | - case AF_INET6: | ||
196 | - proto = IPPROTO_IPV6; | ||
197 | - in_ttl_opt = IPV6_MINHOPCOUNT; | ||
198 | - out_ttl_opt = IPV6_UNICAST_HOPS; | ||
199 | - break; | ||
200 | - default: | ||
201 | - errx(1, "unknown address family: %d", af); | ||
202 | - } | ||
203 | - if (minttl != -1 && setsockopt(s, proto, in_ttl_opt, | ||
204 | - &minttl, sizeof(minttl))) | ||
205 | - err(1, "setsockopt minttl"); | ||
206 | - if (ttl != -1 && setsockopt(s, proto, out_ttl_opt, | ||
207 | - &ttl, sizeof(ttl))) | ||
208 | - err(1, "setsockopt ttl"); | ||
209 | + | ||
210 | + if (ttl != -1) { | ||
211 | + if (af == AF_INET && setsockopt(s, IPPROTO_IP, | ||
212 | + IP_TTL, &ttl, sizeof(ttl))) | ||
213 | + err(1, "setsockopt IP_TTL"); | ||
214 | + | ||
215 | + else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, | ||
216 | + IPV6_UNICAST_HOPS, &ttl, sizeof(ttl))) | ||
217 | + err(1, "setsockopt IPV6_UNICAST_HOPS"); | ||
218 | } | ||
219 | + | ||
220 | + if (minttl != -1) { | ||
221 | + if (af == AF_INET && setsockopt(s, IPPROTO_IP, | ||
222 | + IP_MINTTL, &minttl, sizeof(minttl))) | ||
223 | + err(1, "setsockopt IP_MINTTL"); | ||
224 | + | ||
225 | +#ifdef IPV6_MINHOPCOUNT | ||
226 | + else if (af == AF_INET6 && setsockopt(s, IPPROTO_IPV6, | ||
227 | + IPV6_MINHOPCOUNT, &minttl, sizeof(minttl))) | ||
228 | + err(1, "setsockopt IPV6_MINHOPCOUNT"); | ||
229 | +#endif | ||
230 | + } | ||
231 | } | ||
232 | |||
233 | int | ||
234 | @@ -1613,14 +1638,22 @@ | ||
160 | \t-P proxyuser\tUsername for proxy authentication\n\ | 235 | \t-P proxyuser\tUsername for proxy authentication\n\ |
161 | \t-p port\t Specify local port for remote connects\n\ | 236 | \t-p port\t Specify local port for remote connects\n\ |
162 | \t-R CAfile CA bundle\n\ | 237 | \t-R CAfile CA bundle\n\ |