1 |
commit: c66ee6eae7e62e36caad12950a995cfff43fbb0b |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jun 17 18:43:48 2021 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jun 17 18:44:02 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c66ee6ea |
7 |
|
8 |
net-analyzer/openbsd-netcat-1.195-r1: fix build for musl and Darwin |
9 |
|
10 |
Package-Manager: Portage-3.0.18, Repoman-3.0.2 |
11 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
12 |
|
13 |
.../files/openbsd-netcat-1.105-musl-b64_ntop.patch | 349 +++++++++++++++++++++ |
14 |
.../files/openbsd-netcat-1.190-darwin.patch | 44 --- |
15 |
.../files/openbsd-netcat-1.190-darwin13.patch | 50 +++ |
16 |
...win.patch => openbsd-netcat-1.195-darwin.patch} | 54 +--- |
17 |
.../openbsd-netcat/openbsd-netcat-1.195-r1.ebuild | 62 ++++ |
18 |
5 files changed, 471 insertions(+), 88 deletions(-) |
19 |
|
20 |
diff --git a/net-analyzer/openbsd-netcat/files/openbsd-netcat-1.105-musl-b64_ntop.patch b/net-analyzer/openbsd-netcat/files/openbsd-netcat-1.105-musl-b64_ntop.patch |
21 |
new file mode 100644 |
22 |
index 00000000000..a9603b38bc0 |
23 |
--- /dev/null |
24 |
+++ b/net-analyzer/openbsd-netcat/files/openbsd-netcat-1.105-musl-b64_ntop.patch |
25 |
@@ -0,0 +1,349 @@ |
26 |
+diff -Naur netcat-openbsd-1.105.orig/Makefile netcat-openbsd-1.105/Makefile |
27 |
+--- netcat-openbsd-1.105.orig/Makefile 2017-06-18 09:01:44.293852659 -0700 |
28 |
++++ netcat-openbsd-1.105/Makefile 2017-06-18 09:04:35.566687655 -0700 |
29 |
+@@ -1,7 +1,7 @@ |
30 |
+ # $OpenBSD: Makefile,v 1.6 2001/09/02 18:45:41 jakob Exp $ |
31 |
+ |
32 |
+ PROG= nc |
33 |
+-SRCS= netcat.c atomicio.c socks.c |
34 |
++SRCS= netcat.c atomicio.c socks.c compat/base64.c |
35 |
+ |
36 |
+ LIBS= `pkg-config --libs libbsd` -lresolv |
37 |
+ OBJS= $(SRCS:.c=.o) |
38 |
+diff -Naur netcat-openbsd-1.105.orig/compat/base64.c netcat-openbsd-1.105/compat/base64.c |
39 |
+--- netcat-openbsd-1.105.orig/compat/base64.c 1969-12-31 16:00:00.000000000 -0800 |
40 |
++++ netcat-openbsd-1.105/compat/base64.c 2017-06-18 09:01:31.288700637 -0700 |
41 |
+@@ -0,0 +1,315 @@ |
42 |
++/* $OpenBSD: base64.c,v 1.8 2015/01/16 16:48:51 deraadt Exp $ */ |
43 |
++ |
44 |
++/* |
45 |
++ * Copyright (c) 1996 by Internet Software Consortium. |
46 |
++ * |
47 |
++ * Permission to use, copy, modify, and distribute this software for any |
48 |
++ * purpose with or without fee is hereby granted, provided that the above |
49 |
++ * copyright notice and this permission notice appear in all copies. |
50 |
++ * |
51 |
++ * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS |
52 |
++ * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES |
53 |
++ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE |
54 |
++ * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
55 |
++ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
56 |
++ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS |
57 |
++ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS |
58 |
++ * SOFTWARE. |
59 |
++ */ |
60 |
++ |
61 |
++/* |
62 |
++ * Portions Copyright (c) 1995 by International Business Machines, Inc. |
63 |
++ * |
64 |
++ * International Business Machines, Inc. (hereinafter called IBM) grants |
65 |
++ * permission under its copyrights to use, copy, modify, and distribute this |
66 |
++ * Software with or without fee, provided that the above copyright notice and |
67 |
++ * all paragraphs of this notice appear in all copies, and that the name of IBM |
68 |
++ * not be used in connection with the marketing of any product incorporating |
69 |
++ * the Software or modifications thereof, without specific, written prior |
70 |
++ * permission. |
71 |
++ * |
72 |
++ * To the extent it has a right to do so, IBM grants an immunity from suit |
73 |
++ * under its patents, if any, for the use, sale or manufacture of products to |
74 |
++ * the extent that such products are used for performing Domain Name System |
75 |
++ * dynamic updates in TCP/IP networks by means of the Software. No immunity is |
76 |
++ * granted for any product per se or for any other function of any product. |
77 |
++ * |
78 |
++ * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES, |
79 |
++ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
80 |
++ * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, |
81 |
++ * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING |
82 |
++ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN |
83 |
++ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. |
84 |
++ */ |
85 |
++ |
86 |
++#include <sys/types.h> |
87 |
++#include <sys/socket.h> |
88 |
++#include <netinet/in.h> |
89 |
++#include <arpa/inet.h> |
90 |
++#include <arpa/nameser.h> |
91 |
++ |
92 |
++#include <ctype.h> |
93 |
++#include <resolv.h> |
94 |
++#include <stdio.h> |
95 |
++ |
96 |
++#include <stdlib.h> |
97 |
++#include <string.h> |
98 |
++ |
99 |
++static const char Base64[] = |
100 |
++ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
101 |
++static const char Pad64 = '='; |
102 |
++ |
103 |
++/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt) |
104 |
++ The following encoding technique is taken from RFC 1521 by Borenstein |
105 |
++ and Freed. It is reproduced here in a slightly edited form for |
106 |
++ convenience. |
107 |
++ |
108 |
++ A 65-character subset of US-ASCII is used, enabling 6 bits to be |
109 |
++ represented per printable character. (The extra 65th character, "=", |
110 |
++ is used to signify a special processing function.) |
111 |
++ |
112 |
++ The encoding process represents 24-bit groups of input bits as output |
113 |
++ strings of 4 encoded characters. Proceeding from left to right, a |
114 |
++ 24-bit input group is formed by concatenating 3 8-bit input groups. |
115 |
++ These 24 bits are then treated as 4 concatenated 6-bit groups, each |
116 |
++ of which is translated into a single digit in the base64 alphabet. |
117 |
++ |
118 |
++ Each 6-bit group is used as an index into an array of 64 printable |
119 |
++ characters. The character referenced by the index is placed in the |
120 |
++ output string. |
121 |
++ |
122 |
++ Table 1: The Base64 Alphabet |
123 |
++ |
124 |
++ Value Encoding Value Encoding Value Encoding Value Encoding |
125 |
++ 0 A 17 R 34 i 51 z |
126 |
++ 1 B 18 S 35 j 52 0 |
127 |
++ 2 C 19 T 36 k 53 1 |
128 |
++ 3 D 20 U 37 l 54 2 |
129 |
++ 4 E 21 V 38 m 55 3 |
130 |
++ 5 F 22 W 39 n 56 4 |
131 |
++ 6 G 23 X 40 o 57 5 |
132 |
++ 7 H 24 Y 41 p 58 6 |
133 |
++ 8 I 25 Z 42 q 59 7 |
134 |
++ 9 J 26 a 43 r 60 8 |
135 |
++ 10 K 27 b 44 s 61 9 |
136 |
++ 11 L 28 c 45 t 62 + |
137 |
++ 12 M 29 d 46 u 63 / |
138 |
++ 13 N 30 e 47 v |
139 |
++ 14 O 31 f 48 w (pad) = |
140 |
++ 15 P 32 g 49 x |
141 |
++ 16 Q 33 h 50 y |
142 |
++ |
143 |
++ Special processing is performed if fewer than 24 bits are available |
144 |
++ at the end of the data being encoded. A full encoding quantum is |
145 |
++ always completed at the end of a quantity. When fewer than 24 input |
146 |
++ bits are available in an input group, zero bits are added (on the |
147 |
++ right) to form an integral number of 6-bit groups. Padding at the |
148 |
++ end of the data is performed using the '=' character. |
149 |
++ |
150 |
++ Since all base64 input is an integral number of octets, only the |
151 |
++ ------------------------------------------------- |
152 |
++ following cases can arise: |
153 |
++ |
154 |
++ (1) the final quantum of encoding input is an integral |
155 |
++ multiple of 24 bits; here, the final unit of encoded |
156 |
++ output will be an integral multiple of 4 characters |
157 |
++ with no "=" padding, |
158 |
++ (2) the final quantum of encoding input is exactly 8 bits; |
159 |
++ here, the final unit of encoded output will be two |
160 |
++ characters followed by two "=" padding characters, or |
161 |
++ (3) the final quantum of encoding input is exactly 16 bits; |
162 |
++ here, the final unit of encoded output will be three |
163 |
++ characters followed by one "=" padding character. |
164 |
++ */ |
165 |
++ |
166 |
++int |
167 |
++b64_ntop(src, srclength, target, targsize) |
168 |
++ u_char const *src; |
169 |
++ size_t srclength; |
170 |
++ char *target; |
171 |
++ size_t targsize; |
172 |
++{ |
173 |
++ size_t datalength = 0; |
174 |
++ u_char input[3]; |
175 |
++ u_char output[4]; |
176 |
++ int i; |
177 |
++ |
178 |
++ while (2 < srclength) { |
179 |
++ input[0] = *src++; |
180 |
++ input[1] = *src++; |
181 |
++ input[2] = *src++; |
182 |
++ srclength -= 3; |
183 |
++ |
184 |
++ output[0] = input[0] >> 2; |
185 |
++ output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); |
186 |
++ output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); |
187 |
++ output[3] = input[2] & 0x3f; |
188 |
++ |
189 |
++ if (datalength + 4 > targsize) |
190 |
++ return (-1); |
191 |
++ target[datalength++] = Base64[output[0]]; |
192 |
++ target[datalength++] = Base64[output[1]]; |
193 |
++ target[datalength++] = Base64[output[2]]; |
194 |
++ target[datalength++] = Base64[output[3]]; |
195 |
++ } |
196 |
++ |
197 |
++ /* Now we worry about padding. */ |
198 |
++ if (0 != srclength) { |
199 |
++ /* Get what's left. */ |
200 |
++ input[0] = input[1] = input[2] = '\0'; |
201 |
++ for (i = 0; i < srclength; i++) |
202 |
++ input[i] = *src++; |
203 |
++ |
204 |
++ output[0] = input[0] >> 2; |
205 |
++ output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); |
206 |
++ output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); |
207 |
++ |
208 |
++ if (datalength + 4 > targsize) |
209 |
++ return (-1); |
210 |
++ target[datalength++] = Base64[output[0]]; |
211 |
++ target[datalength++] = Base64[output[1]]; |
212 |
++ if (srclength == 1) |
213 |
++ target[datalength++] = Pad64; |
214 |
++ else |
215 |
++ target[datalength++] = Base64[output[2]]; |
216 |
++ target[datalength++] = Pad64; |
217 |
++ } |
218 |
++ if (datalength >= targsize) |
219 |
++ return (-1); |
220 |
++ target[datalength] = '\0'; /* Returned value doesn't count \0. */ |
221 |
++ return (datalength); |
222 |
++} |
223 |
++ |
224 |
++/* skips all whitespace anywhere. |
225 |
++ converts characters, four at a time, starting at (or after) |
226 |
++ src from base - 64 numbers into three 8 bit bytes in the target area. |
227 |
++ it returns the number of data bytes stored at the target, or -1 on error. |
228 |
++ */ |
229 |
++ |
230 |
++int |
231 |
++b64_pton(src, target, targsize) |
232 |
++ char const *src; |
233 |
++ u_char *target; |
234 |
++ size_t targsize; |
235 |
++{ |
236 |
++ int tarindex, state, ch; |
237 |
++ u_char nextbyte; |
238 |
++ char *pos; |
239 |
++ |
240 |
++ state = 0; |
241 |
++ tarindex = 0; |
242 |
++ |
243 |
++ while ((ch = (unsigned char)*src++) != '\0') { |
244 |
++ if (isspace(ch)) /* Skip whitespace anywhere. */ |
245 |
++ continue; |
246 |
++ |
247 |
++ if (ch == Pad64) |
248 |
++ break; |
249 |
++ |
250 |
++ pos = strchr(Base64, ch); |
251 |
++ if (pos == 0) /* A non-base64 character. */ |
252 |
++ return (-1); |
253 |
++ |
254 |
++ switch (state) { |
255 |
++ case 0: |
256 |
++ if (target) { |
257 |
++ if (tarindex >= targsize) |
258 |
++ return (-1); |
259 |
++ target[tarindex] = (pos - Base64) << 2; |
260 |
++ } |
261 |
++ state = 1; |
262 |
++ break; |
263 |
++ case 1: |
264 |
++ if (target) { |
265 |
++ if (tarindex >= targsize) |
266 |
++ return (-1); |
267 |
++ target[tarindex] |= (pos - Base64) >> 4; |
268 |
++ nextbyte = ((pos - Base64) & 0x0f) << 4; |
269 |
++ if (tarindex + 1 < targsize) |
270 |
++ target[tarindex+1] = nextbyte; |
271 |
++ else if (nextbyte) |
272 |
++ return (-1); |
273 |
++ } |
274 |
++ tarindex++; |
275 |
++ state = 2; |
276 |
++ break; |
277 |
++ case 2: |
278 |
++ if (target) { |
279 |
++ if (tarindex >= targsize) |
280 |
++ return (-1); |
281 |
++ target[tarindex] |= (pos - Base64) >> 2; |
282 |
++ nextbyte = ((pos - Base64) & 0x03) << 6; |
283 |
++ if (tarindex + 1 < targsize) |
284 |
++ target[tarindex+1] = nextbyte; |
285 |
++ else if (nextbyte) |
286 |
++ return (-1); |
287 |
++ } |
288 |
++ tarindex++; |
289 |
++ state = 3; |
290 |
++ break; |
291 |
++ case 3: |
292 |
++ if (target) { |
293 |
++ if (tarindex >= targsize) |
294 |
++ return (-1); |
295 |
++ target[tarindex] |= (pos - Base64); |
296 |
++ } |
297 |
++ tarindex++; |
298 |
++ state = 0; |
299 |
++ break; |
300 |
++ } |
301 |
++ } |
302 |
++ |
303 |
++ /* |
304 |
++ * We are done decoding Base-64 chars. Let's see if we ended |
305 |
++ * on a byte boundary, and/or with erroneous trailing characters. |
306 |
++ */ |
307 |
++ |
308 |
++ if (ch == Pad64) { /* We got a pad char. */ |
309 |
++ ch = (unsigned char)*src++; /* Skip it, get next. */ |
310 |
++ switch (state) { |
311 |
++ case 0: /* Invalid = in first position */ |
312 |
++ case 1: /* Invalid = in second position */ |
313 |
++ return (-1); |
314 |
++ |
315 |
++ case 2: /* Valid, means one byte of info */ |
316 |
++ /* Skip any number of spaces. */ |
317 |
++ for (; ch != '\0'; ch = (unsigned char)*src++) |
318 |
++ if (!isspace(ch)) |
319 |
++ break; |
320 |
++ /* Make sure there is another trailing = sign. */ |
321 |
++ if (ch != Pad64) |
322 |
++ return (-1); |
323 |
++ ch = (unsigned char)*src++; /* Skip the = */ |
324 |
++ /* Fall through to "single trailing =" case. */ |
325 |
++ /* FALLTHROUGH */ |
326 |
++ |
327 |
++ case 3: /* Valid, means two bytes of info */ |
328 |
++ /* |
329 |
++ * We know this char is an =. Is there anything but |
330 |
++ * whitespace after it? |
331 |
++ */ |
332 |
++ for (; ch != '\0'; ch = (unsigned char)*src++) |
333 |
++ if (!isspace(ch)) |
334 |
++ return (-1); |
335 |
++ |
336 |
++ /* |
337 |
++ * Now make sure for cases 2 and 3 that the "extra" |
338 |
++ * bits that slopped past the last full byte were |
339 |
++ * zeros. If we don't check them, they become a |
340 |
++ * subliminal channel. |
341 |
++ */ |
342 |
++ if (target && tarindex < targsize && |
343 |
++ target[tarindex] != 0) |
344 |
++ return (-1); |
345 |
++ } |
346 |
++ } else { |
347 |
++ /* |
348 |
++ * We ended by seeing the end of the string. Make sure we |
349 |
++ * have no partial bytes lying around. |
350 |
++ */ |
351 |
++ if (state != 0) |
352 |
++ return (-1); |
353 |
++ } |
354 |
++ |
355 |
++ return (tarindex); |
356 |
++} |
357 |
+diff -Naur netcat-openbsd-1.105.orig/compat/base64.h netcat-openbsd-1.105/compat/base64.h |
358 |
+--- netcat-openbsd-1.105.orig/compat/base64.h 1969-12-31 16:00:00.000000000 -0800 |
359 |
++++ netcat-openbsd-1.105/compat/base64.h 2017-06-18 09:09:02.057554167 -0700 |
360 |
+@@ -0,0 +1,3 @@ |
361 |
++#include <sys/types.h> |
362 |
++int b64_ntop(u_char const* src, size_t srclength, char *target, size_t targsize); |
363 |
++int b64_pton(char const* src, u_char *target, size_t targsize); |
364 |
+diff -Naur netcat-openbsd-1.105.orig/socks.c netcat-openbsd-1.105/socks.c |
365 |
+--- netcat-openbsd-1.105.orig/socks.c 2017-06-18 09:01:44.293852659 -0700 |
366 |
++++ netcat-openbsd-1.105/socks.c 2017-06-18 09:09:21.105757665 -0700 |
367 |
+@@ -40,6 +40,7 @@ |
368 |
+ #include <resolv.h> |
369 |
+ #include <bsd/readpassphrase.h> |
370 |
+ #include "atomicio.h" |
371 |
++#include "compat/base64.h" |
372 |
+ |
373 |
+ #define SOCKS_PORT "1080" |
374 |
+ #define HTTP_PROXY_PORT "3128" |
375 |
|
376 |
diff --git a/net-analyzer/openbsd-netcat/files/openbsd-netcat-1.190-darwin.patch b/net-analyzer/openbsd-netcat/files/openbsd-netcat-1.190-darwin.patch |
377 |
index a8453c09067..72a3fe8ed9f 100644 |
378 |
--- a/net-analyzer/openbsd-netcat/files/openbsd-netcat-1.190-darwin.patch |
379 |
+++ b/net-analyzer/openbsd-netcat/files/openbsd-netcat-1.190-darwin.patch |
380 |
@@ -34,50 +34,6 @@ index a0fb51b..bbb5dd1 100644 |
381 |
|
382 |
#include "atomicio.h" |
383 |
|
384 |
-@@ -240,6 +243,43 @@ static int connect_with_timeout(int fd, const struct sockaddr *sa, |
385 |
- |
386 |
- static void quit(); |
387 |
- |
388 |
-+static char* strtonumerrs[] = { |
389 |
-+ "too large", |
390 |
-+ "too small", |
391 |
-+ "invalid" |
392 |
-+}; |
393 |
-+ |
394 |
-+static long long |
395 |
-+strtonum( |
396 |
-+ const char *nptr, |
397 |
-+ long long minval, |
398 |
-+ long long maxval, |
399 |
-+ const char **errstr) |
400 |
-+{ |
401 |
-+ long long val; |
402 |
-+ |
403 |
-+ while (*nptr != '\0' && isspace(*nptr)) |
404 |
-+ nptr++; |
405 |
-+ if (*nptr == '\0') { |
406 |
-+ if (errstr != NULL) |
407 |
-+ *errstr = strtonumerrs[2]; |
408 |
-+ return 0; |
409 |
-+ } |
410 |
-+ val = atoll(nptr); |
411 |
-+ if (val < minval) { |
412 |
-+ if (errstr != NULL) |
413 |
-+ *errstr = strtonumerrs[1]; |
414 |
-+ return 0; |
415 |
-+ } |
416 |
-+ if (val > maxval) { |
417 |
-+ if (errstr != NULL) |
418 |
-+ *errstr = strtonumerrs[0]; |
419 |
-+ return 0; |
420 |
-+ } |
421 |
-+ *errstr = NULL; |
422 |
-+ return val; |
423 |
-+} |
424 |
-+ |
425 |
- int |
426 |
- main(int argc, char *argv[]) |
427 |
- { |
428 |
@@ -814,9 +814,8 @@ |
429 |
# endif |
430 |
} else { |
431 |
|
432 |
diff --git a/net-analyzer/openbsd-netcat/files/openbsd-netcat-1.190-darwin13.patch b/net-analyzer/openbsd-netcat/files/openbsd-netcat-1.190-darwin13.patch |
433 |
new file mode 100644 |
434 |
index 00000000000..5a643a2945f |
435 |
--- /dev/null |
436 |
+++ b/net-analyzer/openbsd-netcat/files/openbsd-netcat-1.190-darwin13.patch |
437 |
@@ -0,0 +1,50 @@ |
438 |
+strtonum isn't available on <Darwin-10.15 |
439 |
+ |
440 |
+diff --git a/netcat.c b/netcat.c |
441 |
+index a0fb51b..bbb5dd1 100644 |
442 |
+--- a/netcat.c |
443 |
++++ b/netcat.c |
444 |
+@@ -240,6 +243,43 @@ static int connect_with_timeout(int fd, const struct sockaddr *sa, |
445 |
+ |
446 |
+ static void quit(); |
447 |
+ |
448 |
++static char* strtonumerrs[] = { |
449 |
++ "too large", |
450 |
++ "too small", |
451 |
++ "invalid" |
452 |
++}; |
453 |
++ |
454 |
++static long long |
455 |
++strtonum( |
456 |
++ const char *nptr, |
457 |
++ long long minval, |
458 |
++ long long maxval, |
459 |
++ const char **errstr) |
460 |
++{ |
461 |
++ long long val; |
462 |
++ |
463 |
++ while (*nptr != '\0' && isspace(*nptr)) |
464 |
++ nptr++; |
465 |
++ if (*nptr == '\0') { |
466 |
++ if (errstr != NULL) |
467 |
++ *errstr = strtonumerrs[2]; |
468 |
++ return 0; |
469 |
++ } |
470 |
++ val = atoll(nptr); |
471 |
++ if (val < minval) { |
472 |
++ if (errstr != NULL) |
473 |
++ *errstr = strtonumerrs[1]; |
474 |
++ return 0; |
475 |
++ } |
476 |
++ if (val > maxval) { |
477 |
++ if (errstr != NULL) |
478 |
++ *errstr = strtonumerrs[0]; |
479 |
++ return 0; |
480 |
++ } |
481 |
++ *errstr = NULL; |
482 |
++ return val; |
483 |
++} |
484 |
++ |
485 |
+ int |
486 |
+ main(int argc, char *argv[]) |
487 |
+ { |
488 |
|
489 |
diff --git a/net-analyzer/openbsd-netcat/files/openbsd-netcat-1.190-darwin.patch b/net-analyzer/openbsd-netcat/files/openbsd-netcat-1.195-darwin.patch |
490 |
similarity index 72% |
491 |
copy from net-analyzer/openbsd-netcat/files/openbsd-netcat-1.190-darwin.patch |
492 |
copy to net-analyzer/openbsd-netcat/files/openbsd-netcat-1.195-darwin.patch |
493 |
index a8453c09067..489eceedf6c 100644 |
494 |
--- a/net-analyzer/openbsd-netcat/files/openbsd-netcat-1.190-darwin.patch |
495 |
+++ b/net-analyzer/openbsd-netcat/files/openbsd-netcat-1.195-darwin.patch |
496 |
@@ -34,50 +34,6 @@ index a0fb51b..bbb5dd1 100644 |
497 |
|
498 |
#include "atomicio.h" |
499 |
|
500 |
-@@ -240,6 +243,43 @@ static int connect_with_timeout(int fd, const struct sockaddr *sa, |
501 |
- |
502 |
- static void quit(); |
503 |
- |
504 |
-+static char* strtonumerrs[] = { |
505 |
-+ "too large", |
506 |
-+ "too small", |
507 |
-+ "invalid" |
508 |
-+}; |
509 |
-+ |
510 |
-+static long long |
511 |
-+strtonum( |
512 |
-+ const char *nptr, |
513 |
-+ long long minval, |
514 |
-+ long long maxval, |
515 |
-+ const char **errstr) |
516 |
-+{ |
517 |
-+ long long val; |
518 |
-+ |
519 |
-+ while (*nptr != '\0' && isspace(*nptr)) |
520 |
-+ nptr++; |
521 |
-+ if (*nptr == '\0') { |
522 |
-+ if (errstr != NULL) |
523 |
-+ *errstr = strtonumerrs[2]; |
524 |
-+ return 0; |
525 |
-+ } |
526 |
-+ val = atoll(nptr); |
527 |
-+ if (val < minval) { |
528 |
-+ if (errstr != NULL) |
529 |
-+ *errstr = strtonumerrs[1]; |
530 |
-+ return 0; |
531 |
-+ } |
532 |
-+ if (val > maxval) { |
533 |
-+ if (errstr != NULL) |
534 |
-+ *errstr = strtonumerrs[0]; |
535 |
-+ return 0; |
536 |
-+ } |
537 |
-+ *errstr = NULL; |
538 |
-+ return val; |
539 |
-+} |
540 |
-+ |
541 |
- int |
542 |
- main(int argc, char *argv[]) |
543 |
- { |
544 |
@@ -814,9 +814,8 @@ |
545 |
# endif |
546 |
} else { |
547 |
@@ -128,3 +84,13 @@ index 9068f39..68b68e3 100644 |
548 |
#include "atomicio.h" |
549 |
|
550 |
#define SOCKS_PORT "1080" |
551 |
+--- a/socks.c |
552 |
++++ b/socks.c |
553 |
+@@ -53,5 +53,7 @@ |
554 |
+ #define SOCKS_DOMAIN 3 |
555 |
+ #define SOCKS_IPV6 4 |
556 |
+ |
557 |
++#define explicit_bzero(S,L) bzero(S,L) |
558 |
++ |
559 |
+ int remote_connect(const char *, const char *, struct addrinfo); |
560 |
+ int socks_connect(const char *, const char *, struct addrinfo, |
561 |
|
562 |
diff --git a/net-analyzer/openbsd-netcat/openbsd-netcat-1.195-r1.ebuild b/net-analyzer/openbsd-netcat/openbsd-netcat-1.195-r1.ebuild |
563 |
new file mode 100644 |
564 |
index 00000000000..6fd1b2b6f90 |
565 |
--- /dev/null |
566 |
+++ b/net-analyzer/openbsd-netcat/openbsd-netcat-1.195-r1.ebuild |
567 |
@@ -0,0 +1,62 @@ |
568 |
+# Copyright 1999-2021 Gentoo Authors |
569 |
+# Distributed under the terms of the GNU General Public License v2 |
570 |
+ |
571 |
+EAPI=7 |
572 |
+ |
573 |
+inherit toolchain-funcs |
574 |
+ |
575 |
+DESCRIPTION="The OpenBSD network swiss army knife" |
576 |
+HOMEPAGE="https://cvsweb.openbsd.org/src/usr.bin/nc/ |
577 |
+ https://salsa.debian.org/debian/netcat-openbsd" |
578 |
+SRC_URI="http://http.debian.net/debian/pool/main/n/netcat-openbsd/netcat-openbsd_${PV}.orig.tar.gz |
579 |
+ http://http.debian.net/debian/pool/main/n/netcat-openbsd/netcat-openbsd_${PV}-2.debian.tar.xz" |
580 |
+LICENSE="BSD" |
581 |
+SLOT="0" |
582 |
+IUSE="elibc_Darwin" |
583 |
+ |
584 |
+KEYWORDS="~amd64 ~arm64 ~ppc64 ~x86 ~amd64-linux ~x64-macos" |
585 |
+ |
586 |
+BDEPEND="virtual/pkgconfig" |
587 |
+RDEPEND="!elibc_Darwin? ( dev-libs/libbsd ) |
588 |
+ !net-analyzer/netcat |
589 |
+ !net-analyzer/netcat6 |
590 |
+" |
591 |
+ |
592 |
+S=${WORKDIR}/netcat-openbsd-${PV} |
593 |
+ |
594 |
+src_prepare() { |
595 |
+ for i_patch in $(<"${WORKDIR}"/debian/patches/series); do |
596 |
+ eapply "${WORKDIR}"/debian/patches/"${i_patch}" |
597 |
+ done |
598 |
+ if [[ ${CHOST} == *-darwin* ]] ; then |
599 |
+ # this undoes some of the Debian/Linux changes |
600 |
+ eapply "${FILESDIR}"/${PN}-1.195-darwin.patch |
601 |
+ if [[ ${CHOST##*-darwin} -lt 19 ]] ; then |
602 |
+ eapply "${FILESDIR}"/${PN}-1.190-darwin13.patch |
603 |
+ fi |
604 |
+ fi |
605 |
+ if use elibc_musl ; then |
606 |
+ eapply "${FILESDIR}"/${PN}-1.105-musl-b64_ntop.patch |
607 |
+ fi |
608 |
+ default |
609 |
+} |
610 |
+ |
611 |
+src_compile() { |
612 |
+ emake CC=$(tc-getCC) CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}" |
613 |
+} |
614 |
+ |
615 |
+src_install() { |
616 |
+ dobin nc |
617 |
+ doman nc.1 |
618 |
+ cd "${WORKDIR}"/debian || die |
619 |
+ newdoc netcat-openbsd.README.Debian README |
620 |
+ dodoc -r examples |
621 |
+} |
622 |
+ |
623 |
+pkg_postinst() { |
624 |
+ if [[ ${KERNEL} = "linux" ]]; then |
625 |
+ ewarn "SO_REUSEPORT is introduced in linux 3.9. If your running kernel is older" |
626 |
+ ewarn "and kernel header is newer, nc will not listen correctly. Matching the header" |
627 |
+ ewarn "to the running kernel will do. See bug #490246 for details." |
628 |
+ fi |
629 |
+} |