refresh nc(1) support

This commit is contained in:
Brent Cook 2015-12-06 23:32:18 -06:00
parent 5b49c30cbc
commit 905e2a3b80
4 changed files with 17 additions and 14 deletions

View File

@ -1,5 +1,6 @@
if !HAVE_ARC4RANDOM_BUF if !HAVE_ARC4RANDOM_BUF
libcompat_la_SOURCES += compat/arc4random.c libcompat_la_SOURCES += compat/arc4random.c
libcompat_la_SOURCES += compat/arc4random_uniform.c
if !HAVE_GETENTROPY if !HAVE_GETENTROPY
if HOST_AIX if HOST_AIX

View File

@ -22,6 +22,7 @@
#ifndef HAVE_ARC4RANDOM_BUF #ifndef HAVE_ARC4RANDOM_BUF
uint32_t arc4random(void); uint32_t arc4random(void);
void arc4random_buf(void *_buf, size_t n); void arc4random_buf(void *_buf, size_t n);
uint32_t arc4random_uniform(uint32_t upper_bound);
#endif #endif
#ifndef HAVE_REALLOCARRAY #ifndef HAVE_REALLOCARRAY

View File

@ -1,5 +1,5 @@
--- apps/nc/netcat.c.orig 2015-11-22 09:54:13.947164164 -0600 --- apps/nc/netcat.c.orig Sun Dec 6 22:05:45 2015
+++ apps/nc/netcat.c 2015-11-22 10:49:52.455236524 -0600 +++ apps/nc/netcat.c Sun Dec 6 23:23:15 2015
@@ -57,6 +57,10 @@ @@ -57,6 +57,10 @@
#include <tls.h> #include <tls.h>
#include "atomicio.h" #include "atomicio.h"
@ -9,9 +9,9 @@
+#endif +#endif
+ +
#define PORT_MAX 65535 #define PORT_MAX 65535
#define PORT_MAX_LEN 6
#define UNIX_DG_TMP_SOCKET_SIZE 19 #define UNIX_DG_TMP_SOCKET_SIZE 19
@@ -93,9 +97,13 @@
@@ -92,9 +96,13 @@
int Dflag; /* sodebug */ int Dflag; /* sodebug */
int Iflag; /* TCP receive buffer size */ int Iflag; /* TCP receive buffer size */
int Oflag; /* TCP send buffer size */ int Oflag; /* TCP send buffer size */
@ -25,7 +25,7 @@
int usetls; /* use TLS */ int usetls; /* use TLS */
char *Cflag; /* Public cert file */ char *Cflag; /* Public cert file */
@@ -145,7 +153,7 @@ @@ -144,7 +152,7 @@
struct servent *sv; struct servent *sv;
socklen_t len; socklen_t len;
struct sockaddr_storage cliaddr; struct sockaddr_storage cliaddr;
@ -34,7 +34,7 @@
const char *errstr, *proxyhost = "", *proxyport = NULL; const char *errstr, *proxyhost = "", *proxyport = NULL;
struct addrinfo proxyhints; struct addrinfo proxyhints;
char unix_dg_tmp_socket_buf[UNIX_DG_TMP_SOCKET_SIZE]; char unix_dg_tmp_socket_buf[UNIX_DG_TMP_SOCKET_SIZE];
@@ -246,12 +254,14 @@ @@ -245,12 +253,14 @@
case 'u': case 'u':
uflag = 1; uflag = 1;
break; break;
@ -49,7 +49,7 @@
case 'v': case 'v':
vflag = 1; vflag = 1;
break; break;
@@ -284,9 +294,11 @@ @@ -283,9 +293,11 @@
errx(1, "TCP send window %s: %s", errx(1, "TCP send window %s: %s",
errstr, optarg); errstr, optarg);
break; break;
@ -61,7 +61,7 @@
case 'T': case 'T':
errstr = NULL; errstr = NULL;
errno = 0; errno = 0;
@@ -310,9 +322,11 @@ @@ -309,9 +321,11 @@
argc -= optind; argc -= optind;
argv += optind; argv += optind;
@ -73,7 +73,7 @@
if (family == AF_UNIX) { if (family == AF_UNIX) {
if (pledge("stdio rpath wpath cpath tmppath unix", NULL) == -1) 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) remote_connect(const char *host, const char *port, struct addrinfo hints)
{ {
struct addrinfo *res, *res0; struct addrinfo *res, *res0;
@ -85,7 +85,7 @@
if ((error = getaddrinfo(host, port, &hints, &res))) if ((error = getaddrinfo(host, port, &hints, &res)))
errx(1, "getaddrinfo: %s", gai_strerror(error)); errx(1, "getaddrinfo: %s", gai_strerror(error));
@@ -807,8 +824,10 @@ @@ -806,8 +823,10 @@
if (sflag || pflag) { if (sflag || pflag) {
struct addrinfo ahints, *ares; struct addrinfo ahints, *ares;
@ -96,7 +96,7 @@
memset(&ahints, 0, sizeof(struct addrinfo)); memset(&ahints, 0, sizeof(struct addrinfo));
ahints.ai_family = res0->ai_family; ahints.ai_family = res0->ai_family;
ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM; 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) local_listen(char *host, char *port, struct addrinfo hints)
{ {
struct addrinfo *res, *res0; struct addrinfo *res, *res0;
@ -108,7 +108,7 @@
int error; int error;
/* Allow nodename to be null. */ /* Allow nodename to be null. */
@@ -899,9 +921,11 @@ @@ -898,9 +920,11 @@
res0->ai_protocol)) < 0) res0->ai_protocol)) < 0)
continue; continue;
@ -120,7 +120,7 @@
set_common_sockopts(s, res0->ai_family); set_common_sockopts(s, res0->ai_family);
@@ -1344,11 +1368,13 @@ @@ -1340,11 +1364,13 @@
{ {
int x = 1; int x = 1;
@ -134,7 +134,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)
@@ -1523,15 +1549,19 @@ @@ -1519,15 +1545,19 @@
\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\

View File

@ -73,6 +73,7 @@ $CP $libtls_src/tls.h libtls-standalone/include
for i in crypto/compat libtls-standalone/compat; do for i in crypto/compat libtls-standalone/compat; do
for j in $libc_src/crypt/arc4random.c \ for j in $libc_src/crypt/arc4random.c \
$libc_src/crypt/arc4random_uniform.c \
$libc_src/crypt/chacha_private.h \ $libc_src/crypt/chacha_private.h \
$libc_src/string/explicit_bzero.c \ $libc_src/string/explicit_bzero.c \
$libc_src/stdlib/reallocarray.c \ $libc_src/stdlib/reallocarray.c \