From 905e2a3b8046e227bf02410def56b0c2535de14f Mon Sep 17 00:00:00 2001 From: Brent Cook Date: Sun, 6 Dec 2015 23:32:18 -0600 Subject: refresh nc(1) support --- crypto/Makefile.am.arc4random | 1 + include/compat/stdlib.h | 1 + patches/netcat.c.patch | 28 ++++++++++++++-------------- update.sh | 1 + 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/crypto/Makefile.am.arc4random b/crypto/Makefile.am.arc4random index c44051c..6a01966 100644 --- a/crypto/Makefile.am.arc4random +++ b/crypto/Makefile.am.arc4random @@ -1,5 +1,6 @@ if !HAVE_ARC4RANDOM_BUF libcompat_la_SOURCES += compat/arc4random.c +libcompat_la_SOURCES += compat/arc4random_uniform.c if !HAVE_GETENTROPY if HOST_AIX diff --git a/include/compat/stdlib.h b/include/compat/stdlib.h index 506d463..781be77 100644 --- a/include/compat/stdlib.h +++ b/include/compat/stdlib.h @@ -22,6 +22,7 @@ #ifndef HAVE_ARC4RANDOM_BUF uint32_t arc4random(void); void arc4random_buf(void *_buf, size_t n); +uint32_t arc4random_uniform(uint32_t upper_bound); #endif #ifndef HAVE_REALLOCARRAY diff --git a/patches/netcat.c.patch b/patches/netcat.c.patch index 8f186f6..d914231 100644 --- a/patches/netcat.c.patch +++ b/patches/netcat.c.patch @@ -1,5 +1,5 @@ ---- apps/nc/netcat.c.orig 2015-11-22 09:54:13.947164164 -0600 -+++ apps/nc/netcat.c 2015-11-22 10:49:52.455236524 -0600 +--- apps/nc/netcat.c.orig Sun Dec 6 22:05:45 2015 ++++ apps/nc/netcat.c Sun Dec 6 23:23:15 2015 @@ -57,6 +57,10 @@ #include #include "atomicio.h" @@ -9,9 +9,9 @@ +#endif + #define PORT_MAX 65535 - #define PORT_MAX_LEN 6 #define UNIX_DG_TMP_SOCKET_SIZE 19 -@@ -93,9 +97,13 @@ + +@@ -92,9 +96,13 @@ int Dflag; /* sodebug */ int Iflag; /* TCP receive buffer size */ int Oflag; /* TCP send buffer size */ @@ -25,7 +25,7 @@ int usetls; /* use TLS */ char *Cflag; /* Public cert file */ -@@ -145,7 +153,7 @@ +@@ -144,7 +152,7 @@ struct servent *sv; socklen_t len; struct sockaddr_storage cliaddr; @@ -34,7 +34,7 @@ const char *errstr, *proxyhost = "", *proxyport = NULL; struct addrinfo proxyhints; char unix_dg_tmp_socket_buf[UNIX_DG_TMP_SOCKET_SIZE]; -@@ -246,12 +254,14 @@ +@@ -245,12 +253,14 @@ case 'u': uflag = 1; break; @@ -49,7 +49,7 @@ case 'v': vflag = 1; break; -@@ -284,9 +294,11 @@ +@@ -283,9 +293,11 @@ errx(1, "TCP send window %s: %s", errstr, optarg); break; @@ -61,7 +61,7 @@ case 'T': errstr = NULL; errno = 0; -@@ -310,9 +322,11 @@ +@@ -309,9 +321,11 @@ argc -= optind; argv += optind; @@ -73,7 +73,7 @@ if (family == AF_UNIX) { if (pledge("stdio rpath wpath cpath tmppath unix", NULL) == -1) -@@ -792,7 +806,10 @@ +@@ -791,7 +805,10 @@ remote_connect(const char *host, const char *port, struct addrinfo hints) { struct addrinfo *res, *res0; @@ -85,7 +85,7 @@ if ((error = getaddrinfo(host, port, &hints, &res))) errx(1, "getaddrinfo: %s", gai_strerror(error)); -@@ -807,8 +824,10 @@ +@@ -806,8 +823,10 @@ if (sflag || pflag) { struct addrinfo ahints, *ares; @@ -96,7 +96,7 @@ memset(&ahints, 0, sizeof(struct addrinfo)); ahints.ai_family = res0->ai_family; ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM; -@@ -877,7 +896,10 @@ +@@ -876,7 +895,10 @@ local_listen(char *host, char *port, struct addrinfo hints) { struct addrinfo *res, *res0; @@ -108,7 +108,7 @@ int error; /* Allow nodename to be null. */ -@@ -899,9 +921,11 @@ +@@ -898,9 +920,11 @@ res0->ai_protocol)) < 0) continue; @@ -120,7 +120,7 @@ set_common_sockopts(s, res0->ai_family); -@@ -1344,11 +1368,13 @@ +@@ -1340,11 +1364,13 @@ { int x = 1; @@ -134,7 +134,7 @@ if (Dflag) { if (setsockopt(s, SOL_SOCKET, SO_DEBUG, &x, sizeof(x)) == -1) -@@ -1523,15 +1549,19 @@ +@@ -1519,15 +1545,19 @@ \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\ diff --git a/update.sh b/update.sh index de9f2bb..a456b22 100755 --- a/update.sh +++ b/update.sh @@ -73,6 +73,7 @@ $CP $libtls_src/tls.h libtls-standalone/include for i in crypto/compat libtls-standalone/compat; do for j in $libc_src/crypt/arc4random.c \ + $libc_src/crypt/arc4random_uniform.c \ $libc_src/crypt/chacha_private.h \ $libc_src/string/explicit_bzero.c \ $libc_src/stdlib/reallocarray.c \ -- cgit v1.2.3-55-g6feb