Accepting request 729549 from network:utilities

- Update to 1.203 matching debian
- Remove patch verbose-numeric-port.patch
- Refresh patches:
  * broadcast-support.patch
  * build-without-TLS-support.patch
  * connect-timeout.patch
  * dccp-support.patch
  * destination-port-list.patch
  * get-sev-by-name.patch
  * misc-failures-and-features.patch
  * port-to-linux-with-libsd.patch
  * quit-timer.patch
  * send-crlf.patch
  * serialized-handling-multiple-clients.patch
  * set-TCP-MD5SIG-correctly-for-client-connections.patch
  * udp-scan-timeout.patch
  * use-flags-to-specify-listen-address.patch

OBS-URL: https://build.opensuse.org/request/show/729549
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/netcat-openbsd?expand=0&rev=25
This commit is contained in:
Yuchen Lin 2019-09-19 13:46:22 +00:00 committed by Git OBS Bridge
commit 30c06a486d
19 changed files with 194 additions and 256 deletions

View File

@ -29,7 +29,7 @@ Subject: broadcast support
data is translated into CR+LF before being written to the socket. Line data is translated into CR+LF before being written to the socket. Line
--- a/netcat.c --- a/netcat.c
+++ b/netcat.c +++ b/netcat.c
@@ -133,6 +133,7 @@ @@ -132,6 +132,7 @@
#define UDP_SCAN_TIMEOUT 3 /* Seconds */ #define UDP_SCAN_TIMEOUT 3 /* Seconds */
/* Command Line Options */ /* Command Line Options */
@ -37,7 +37,7 @@ Subject: broadcast support
int dflag; /* detached, no stdin */ int dflag; /* detached, no stdin */
int Fflag; /* fdpass sock to stdout */ int Fflag; /* fdpass sock to stdout */
unsigned int iflag; /* Interval Flag */ unsigned int iflag; /* Interval Flag */
@@ -261,9 +262,9 @@ main(int argc, char *argv[]) @@ -263,9 +264,9 @@ main(int argc, char *argv[])
while ((ch = getopt(argc, argv, while ((ch = getopt(argc, argv,
# if defined(TLS) # if defined(TLS)
@ -49,7 +49,7 @@ Subject: broadcast support
# endif # endif
!= -1) { != -1) {
switch (ch) { switch (ch) {
@@ -273,6 +274,13 @@ main(int argc, char *argv[]) @@ -275,6 +276,13 @@ main(int argc, char *argv[])
case '6': case '6':
family = AF_INET6; family = AF_INET6;
break; break;
@ -63,7 +63,7 @@ Subject: broadcast support
case 'U': case 'U':
family = AF_UNIX; family = AF_UNIX;
break; break;
@@ -1843,6 +1851,15 @@ set_common_sockopts(int s, int af) @@ -1852,6 +1860,15 @@ set_common_sockopts(int s, int af)
{ {
int x = 1; int x = 1;
@ -79,7 +79,7 @@ Subject: broadcast support
# if defined(TCP_MD5SIG) # if defined(TCP_MD5SIG)
if (Sflag) { if (Sflag) {
if (setsockopt(s, IPPROTO_TCP, TCP_MD5SIG, if (setsockopt(s, IPPROTO_TCP, TCP_MD5SIG,
@@ -2122,6 +2139,7 @@ help(void) @@ -2127,6 +2144,7 @@ help(void)
fprintf(stderr, "\tCommand Summary:\n\ fprintf(stderr, "\tCommand Summary:\n\
\t-4 Use IPv4\n\ \t-4 Use IPv4\n\
\t-6 Use IPv6\n\ \t-6 Use IPv6\n\

View File

@ -9,7 +9,7 @@ that are already used by our Debian-specific patches.
Makefile | 2 Makefile | 2
nc.1 | 114 ++--------------------------------------- nc.1 | 114 ++---------------------------------------
netcat.c | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++++---------- netcat.c | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++++----------
3 files changed, 152 insertions(+), 136 deletions(-) 3 files changed, 153 insertions(+), 135 deletions(-)
--- a/Makefile --- a/Makefile
+++ b/Makefile +++ b/Makefile
@ -232,7 +232,7 @@ that are already used by our Debian-specific patches.
.Dl $ nc -u host.example.com 53 .Dl $ nc -u host.example.com 53
--- a/netcat.c --- a/netcat.c
+++ b/netcat.c +++ b/netcat.c
@@ -98,7 +98,9 @@ @@ -99,7 +99,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
@ -243,18 +243,15 @@ that are already used by our Debian-specific patches.
#include <unistd.h> #include <unistd.h>
#include <bsd/stdlib.h> #include <bsd/stdlib.h>
#include <bsd/string.h> #include <bsd/string.h>
@@ -113,12 +115,14 @@ @@ -115,10 +117,12 @@
#define POLL_NETIN 2
#define POLL_STDOUT 3 #define POLL_STDOUT 3
#define BUFSIZE 16384 #define BUFSIZE 16384
-#define DEFAULT_CA_FILE "/etc/ssl/cert.pem"
+#ifdef TLS
+# define DEFAULT_CA_FILE "/etc/ssl/cert.pem"
-#define TLS_NOVERIFY (1 << 1) -#define TLS_NOVERIFY (1 << 1)
-#define TLS_NONAME (1 << 2) -#define TLS_NONAME (1 << 2)
-#define TLS_CCERT (1 << 3) -#define TLS_CCERT (1 << 3)
-#define TLS_MUSTSTAPLE (1 << 4) -#define TLS_MUSTSTAPLE (1 << 4)
+#ifdef TLS
+# define TLS_NOVERIFY (1 << 1) +# define TLS_NOVERIFY (1 << 1)
+# define TLS_NONAME (1 << 2) +# define TLS_NONAME (1 << 2)
+# define TLS_CCERT (1 << 3) +# define TLS_CCERT (1 << 3)
@ -269,8 +266,8 @@ that are already used by our Debian-specific patches.
+# if defined(TLS) +# if defined(TLS)
int usetls; /* use TLS */ int usetls; /* use TLS */
char *Cflag; /* Public cert file */ const char *Cflag; /* Public cert file */
char *Kflag; /* Private key file */ const char *Kflag; /* Private key file */
@@ -156,6 +161,7 @@ char *tls_expecthash; /* required hash @@ -156,6 +161,7 @@ char *tls_expecthash; /* required hash
char *tls_ciphers; /* TLS ciphers */ char *tls_ciphers; /* TLS ciphers */
char *tls_protocols; /* TLS protocols */ char *tls_protocols; /* TLS protocols */
@ -304,7 +301,7 @@ that are already used by our Debian-specific patches.
int process_tls_opt(char *, int *); int process_tls_opt(char *, int *);
void save_peer_cert(struct tls *_tls_ctx, FILE *_fp); void save_peer_cert(struct tls *_tls_ctx, FILE *_fp);
+# endif +# endif
void report_connect(const struct sockaddr *, socklen_t, char *); void report_sock(const char *, const struct sockaddr *, socklen_t, char *);
+# if defined(TLS) +# if defined(TLS)
void report_tls(struct tls *tls_ctx, char * host); void report_tls(struct tls *tls_ctx, char * host);
+# endif +# endif
@ -332,7 +329,14 @@ that are already used by our Debian-specific patches.
uint32_t protocols; uint32_t protocols;
ret = 1; ret = 1;
@@ -219,7 +242,11 @@ main(int argc, char *argv[]) @@ -215,12 +238,18 @@ main(int argc, char *argv[])
host = NULL;
uport = NULL;
sv = NULL;
+# if defined(TLS)
Rflag = tls_default_ca_cert_file();
+# endif
signal(SIGPIPE, SIG_IGN); signal(SIGPIPE, SIG_IGN);
while ((ch = getopt(argc, argv, while ((ch = getopt(argc, argv,
@ -344,7 +348,7 @@ that are already used by our Debian-specific patches.
!= -1) { != -1) {
switch (ch) { switch (ch) {
case '4': case '4':
@@ -241,24 +268,30 @@ main(int argc, char *argv[]) @@ -242,24 +271,30 @@ main(int argc, char *argv[])
else else
errx(1, "unsupported proxy protocol"); errx(1, "unsupported proxy protocol");
break; break;
@ -375,7 +379,7 @@ that are already used by our Debian-specific patches.
case 'h': case 'h':
help(); help();
break; break;
@@ -267,9 +300,11 @@ main(int argc, char *argv[]) @@ -268,9 +303,11 @@ main(int argc, char *argv[])
if (errstr) if (errstr)
errx(1, "interval %s: %s", errstr, optarg); errx(1, "interval %s: %s", errstr, optarg);
break; break;
@ -387,7 +391,7 @@ that are already used by our Debian-specific patches.
case 'k': case 'k':
kflag = 1; kflag = 1;
break; break;
@@ -298,10 +333,12 @@ main(int argc, char *argv[]) @@ -299,10 +336,12 @@ main(int argc, char *argv[])
case 'p': case 'p':
pflag = optarg; pflag = optarg;
break; break;
@ -400,7 +404,7 @@ that are already used by our Debian-specific patches.
case 'r': case 'r':
rflag = 1; rflag = 1;
break; break;
@@ -343,12 +380,14 @@ main(int argc, char *argv[]) @@ -344,12 +383,14 @@ main(int argc, char *argv[])
if ((proxy = strdup(optarg)) == NULL) if ((proxy = strdup(optarg)) == NULL)
err(1, NULL); err(1, NULL);
break; break;
@ -415,7 +419,7 @@ that are already used by our Debian-specific patches.
case 'z': case 'z':
zflag = 1; zflag = 1;
break; break;
@@ -367,9 +406,11 @@ main(int argc, char *argv[]) @@ -368,9 +409,11 @@ main(int argc, char *argv[])
errx(1, "TCP send window %s: %s", errx(1, "TCP send window %s: %s",
errstr, optarg); errstr, optarg);
break; break;
@ -427,7 +431,7 @@ that are already used by our Debian-specific patches.
case 'S': case 'S':
# if defined(TCP_MD5SIG) # if defined(TCP_MD5SIG)
Sflag = 1; Sflag = 1;
@@ -380,8 +421,10 @@ main(int argc, char *argv[]) @@ -381,8 +424,10 @@ main(int argc, char *argv[])
case 'T': case 'T':
errstr = NULL; errstr = NULL;
errno = 0; errno = 0;
@ -438,7 +442,7 @@ that are already used by our Debian-specific patches.
if (process_tos_opt(optarg, &Tflag)) if (process_tos_opt(optarg, &Tflag))
break; break;
if (strlen(optarg) > 1 && optarg[0] == '0' && if (strlen(optarg) > 1 && optarg[0] == '0' &&
@@ -391,7 +434,11 @@ main(int argc, char *argv[]) @@ -392,7 +437,11 @@ main(int argc, char *argv[])
Tflag = (int)strtonum(optarg, 0, 255, Tflag = (int)strtonum(optarg, 0, 255,
&errstr); &errstr);
if (Tflag < 0 || Tflag > 255 || errstr || errno) if (Tflag < 0 || Tflag > 255 || errstr || errno)
@ -450,7 +454,7 @@ that are already used by our Debian-specific patches.
break; break;
default: default:
usage(1); usage(1);
@@ -428,6 +475,7 @@ main(int argc, char *argv[]) @@ -429,6 +478,7 @@ main(int argc, char *argv[])
} else } else
usage(1); usage(1);
@ -458,7 +462,7 @@ that are already used by our Debian-specific patches.
if (usetls) { if (usetls) {
if (Cflag && unveil(Cflag, "r") == -1) if (Cflag && unveil(Cflag, "r") == -1)
err(1, "unveil"); err(1, "unveil");
@@ -450,15 +498,19 @@ main(int argc, char *argv[]) @@ -451,15 +501,19 @@ main(int argc, char *argv[])
err(1, "unveil"); err(1, "unveil");
} }
} }
@ -478,7 +482,7 @@ that are already used by our Debian-specific patches.
if (Fflag && usetls) if (Fflag && usetls)
errx(1, "cannot use -c and -F"); errx(1, "cannot use -c and -F");
if (TLSopt && !usetls) if (TLSopt && !usetls)
@@ -477,6 +529,7 @@ main(int argc, char *argv[]) @@ -478,6 +532,7 @@ main(int argc, char *argv[])
errx(1, "you must specify -c to use -H"); errx(1, "you must specify -c to use -H");
if (tls_expectname && !usetls) if (tls_expectname && !usetls)
errx(1, "you must specify -c to use -e"); errx(1, "you must specify -c to use -e");
@ -486,7 +490,7 @@ that are already used by our Debian-specific patches.
/* Get name of temporary socket for unix datagram client */ /* Get name of temporary socket for unix datagram client */
if ((family == AF_UNIX) && uflag && !lflag) { if ((family == AF_UNIX) && uflag && !lflag) {
@@ -543,6 +596,7 @@ main(int argc, char *argv[]) @@ -544,6 +599,7 @@ main(int argc, char *argv[])
proxyhints.ai_flags |= AI_NUMERICHOST; proxyhints.ai_flags |= AI_NUMERICHOST;
} }
@ -494,7 +498,7 @@ that are already used by our Debian-specific patches.
if (usetls) { if (usetls) {
if ((tls_cfg = tls_config_new()) == NULL) if ((tls_cfg = tls_config_new()) == NULL)
errx(1, "unable to allocate TLS config"); errx(1, "unable to allocate TLS config");
@@ -578,7 +632,8 @@ main(int argc, char *argv[]) @@ -579,7 +635,8 @@ main(int argc, char *argv[])
err(1, "pledge"); err(1, "pledge");
} else if (pledge("stdio inet dns", NULL) == -1) } else if (pledge("stdio inet dns", NULL) == -1)
err(1, "pledge"); err(1, "pledge");
@ -504,7 +508,7 @@ that are already used by our Debian-specific patches.
if (lflag) { if (lflag) {
ret = 0; ret = 0;
@@ -589,6 +644,7 @@ main(int argc, char *argv[]) @@ -590,6 +647,7 @@ main(int argc, char *argv[])
s = unix_listen(host); s = unix_listen(host);
} }
@ -512,7 +516,7 @@ that are already used by our Debian-specific patches.
if (usetls) { if (usetls) {
tls_config_verify_client_optional(tls_cfg); tls_config_verify_client_optional(tls_cfg);
if ((tls_ctx = tls_server()) == NULL) if ((tls_ctx = tls_server()) == NULL)
@@ -597,6 +653,7 @@ main(int argc, char *argv[]) @@ -598,6 +656,7 @@ main(int argc, char *argv[])
errx(1, "tls configuration failed (%s)", errx(1, "tls configuration failed (%s)",
tls_error(tls_ctx)); tls_error(tls_ctx));
} }
@ -520,7 +524,7 @@ that are already used by our Debian-specific patches.
/* Allow only one connection at a time, but stay alive. */ /* Allow only one connection at a time, but stay alive. */
for (;;) { for (;;) {
if (family != AF_UNIX) { if (family != AF_UNIX) {
@@ -612,7 +669,11 @@ main(int argc, char *argv[]) @@ -613,7 +672,11 @@ main(int argc, char *argv[])
* let it receive datagrams from multiple * let it receive datagrams from multiple
* socket pairs. * socket pairs.
*/ */
@ -532,9 +536,9 @@ that are already used by our Debian-specific patches.
} else if (uflag && !kflag) { } else if (uflag && !kflag) {
/* /*
* For UDP and not -k, we will use recvfrom() * For UDP and not -k, we will use recvfrom()
@@ -636,9 +697,14 @@ main(int argc, char *argv[]) @@ -638,9 +701,14 @@ main(int argc, char *argv[])
if (vflag) report_sock("Connection received",
report_connect((struct sockaddr *)&z, len, NULL); (struct sockaddr *)&z, len, NULL);
+# if defined(TLS) +# if defined(TLS)
readwrite(s, NULL); readwrite(s, NULL);
@ -547,15 +551,15 @@ that are already used by our Debian-specific patches.
int connfd; int connfd;
len = sizeof(cliaddr); len = sizeof(cliaddr);
@@ -651,6 +717,7 @@ main(int argc, char *argv[]) @@ -654,6 +722,7 @@ main(int argc, char *argv[])
if (vflag) report_sock("Connection received",
report_connect((struct sockaddr *)&cliaddr, len, (struct sockaddr *)&cliaddr, len,
family == AF_UNIX ? host : NULL); family == AF_UNIX ? host : NULL);
+# if defined(TLS) +# if defined(TLS)
if ((usetls) && if ((usetls) &&
(tls_cctx = tls_setup_server(tls_ctx, connfd, host))) (tls_cctx = tls_setup_server(tls_ctx, connfd, host)))
readwrite(connfd, tls_cctx); readwrite(connfd, tls_cctx);
@@ -660,6 +727,10 @@ main(int argc, char *argv[]) @@ -663,6 +732,10 @@ main(int argc, char *argv[])
timeout_tls(s, tls_cctx, tls_close); timeout_tls(s, tls_cctx, tls_close);
close(connfd); close(connfd);
tls_free(tls_cctx); tls_free(tls_cctx);
@ -566,7 +570,7 @@ that are already used by our Debian-specific patches.
} }
if (family == AF_UNIX && uflag) { if (family == AF_UNIX && uflag) {
if (connect(s, NULL, 0) < 0) if (connect(s, NULL, 0) < 0)
@@ -674,7 +745,11 @@ main(int argc, char *argv[]) @@ -677,7 +750,11 @@ main(int argc, char *argv[])
if ((s = unix_connect(host)) > 0) { if ((s = unix_connect(host)) > 0) {
if (!zflag) if (!zflag)
@ -576,9 +580,9 @@ that are already used by our Debian-specific patches.
+ readwrite(s); + readwrite(s);
+# endif +# endif
close(s); close(s);
} else } else {
ret = 1; warn("%s", host);
@@ -693,6 +768,7 @@ main(int argc, char *argv[]) @@ -698,6 +775,7 @@ main(int argc, char *argv[])
for (s = -1, i = 0; portlist[i] != NULL; i++) { for (s = -1, i = 0; portlist[i] != NULL; i++) {
if (s != -1) if (s != -1)
close(s); close(s);
@ -586,7 +590,7 @@ that are already used by our Debian-specific patches.
tls_free(tls_ctx); tls_free(tls_ctx);
tls_ctx = NULL; tls_ctx = NULL;
@@ -703,6 +779,7 @@ main(int argc, char *argv[]) @@ -708,6 +786,7 @@ main(int argc, char *argv[])
errx(1, "tls configuration failed (%s)", errx(1, "tls configuration failed (%s)",
tls_error(tls_ctx)); tls_error(tls_ctx));
} }
@ -594,7 +598,7 @@ that are already used by our Debian-specific patches.
if (xflag) if (xflag)
s = socks_connect(host, portlist[i], hints, s = socks_connect(host, portlist[i], hints,
proxy, proxyport, proxyhints, socksv, proxy, proxyport, proxyhints, socksv,
@@ -740,6 +817,7 @@ main(int argc, char *argv[]) @@ -745,6 +824,7 @@ main(int argc, char *argv[])
} }
if (Fflag) if (Fflag)
fdpass(s); fdpass(s);
@ -602,7 +606,7 @@ that are already used by our Debian-specific patches.
else { else {
if (usetls) if (usetls)
tls_setup_client(tls_ctx, s, host); tls_setup_client(tls_ctx, s, host);
@@ -748,13 +826,19 @@ main(int argc, char *argv[]) @@ -753,13 +833,19 @@ main(int argc, char *argv[])
if (tls_ctx) if (tls_ctx)
timeout_tls(s, tls_ctx, tls_close); timeout_tls(s, tls_ctx, tls_close);
} }
@ -622,7 +626,7 @@ that are already used by our Debian-specific patches.
return ret; return ret;
} }
@@ -794,6 +878,7 @@ unix_bind(char *path, int flags) @@ -801,6 +887,7 @@ unix_bind(char *path, int flags)
return s; return s;
} }
@ -630,7 +634,7 @@ that are already used by our Debian-specific patches.
int int
timeout_tls(int s, struct tls *tls_ctx, int (*func)(struct tls *)) timeout_tls(int s, struct tls *tls_ctx, int (*func)(struct tls *))
{ {
@@ -880,6 +965,7 @@ tls_setup_server(struct tls *tls_ctx, in @@ -887,6 +974,7 @@ tls_setup_server(struct tls *tls_ctx, in
} }
return NULL; return NULL;
} }
@ -638,7 +642,7 @@ that are already used by our Debian-specific patches.
/* /*
* unix_connect() * unix_connect()
@@ -1092,7 +1178,11 @@ local_listen(const char *host, const cha @@ -1112,7 +1200,11 @@ local_listen(const char *host, const cha
* Loop that polls on the network file descriptor and stdin. * Loop that polls on the network file descriptor and stdin.
*/ */
void void
@ -650,7 +654,7 @@ that are already used by our Debian-specific patches.
{ {
struct pollfd pfd[4]; struct pollfd pfd[4];
int stdin_fd = STDIN_FILENO; int stdin_fd = STDIN_FILENO;
@@ -1192,12 +1282,17 @@ readwrite(int net_fd, struct tls *tls_ct @@ -1212,12 +1304,17 @@ readwrite(int net_fd, struct tls *tls_ct
/* try to read from stdin */ /* try to read from stdin */
if (pfd[POLL_STDIN].revents & POLLIN && stdinbufpos < BUFSIZE) { if (pfd[POLL_STDIN].revents & POLLIN && stdinbufpos < BUFSIZE) {
ret = fillbuf(pfd[POLL_STDIN].fd, stdinbuf, ret = fillbuf(pfd[POLL_STDIN].fd, stdinbuf,
@ -669,7 +673,7 @@ that are already used by our Debian-specific patches.
pfd[POLL_STDIN].fd = -1; pfd[POLL_STDIN].fd = -1;
/* read something - poll net out */ /* read something - poll net out */
if (stdinbufpos > 0) if (stdinbufpos > 0)
@@ -1209,12 +1304,17 @@ readwrite(int net_fd, struct tls *tls_ct @@ -1229,12 +1326,17 @@ readwrite(int net_fd, struct tls *tls_ct
/* try to write to network */ /* try to write to network */
if (pfd[POLL_NETOUT].revents & POLLOUT && stdinbufpos > 0) { if (pfd[POLL_NETOUT].revents & POLLOUT && stdinbufpos > 0) {
ret = drainbuf(pfd[POLL_NETOUT].fd, stdinbuf, ret = drainbuf(pfd[POLL_NETOUT].fd, stdinbuf,
@ -688,7 +692,7 @@ that are already used by our Debian-specific patches.
pfd[POLL_NETOUT].fd = -1; pfd[POLL_NETOUT].fd = -1;
/* buffer empty - remove self from polling */ /* buffer empty - remove self from polling */
if (stdinbufpos == 0) if (stdinbufpos == 0)
@@ -1226,12 +1326,17 @@ readwrite(int net_fd, struct tls *tls_ct @@ -1246,12 +1348,17 @@ readwrite(int net_fd, struct tls *tls_ct
/* try to read from network */ /* try to read from network */
if (pfd[POLL_NETIN].revents & POLLIN && netinbufpos < BUFSIZE) { if (pfd[POLL_NETIN].revents & POLLIN && netinbufpos < BUFSIZE) {
ret = fillbuf(pfd[POLL_NETIN].fd, netinbuf, ret = fillbuf(pfd[POLL_NETIN].fd, netinbuf,
@ -707,7 +711,7 @@ that are already used by our Debian-specific patches.
pfd[POLL_NETIN].fd = -1; pfd[POLL_NETIN].fd = -1;
/* eof on net in - remove from pfd */ /* eof on net in - remove from pfd */
if (ret == 0) { if (ret == 0) {
@@ -1258,12 +1363,17 @@ readwrite(int net_fd, struct tls *tls_ct @@ -1278,12 +1385,17 @@ readwrite(int net_fd, struct tls *tls_ct
/* try to write to stdout */ /* try to write to stdout */
if (pfd[POLL_STDOUT].revents & POLLOUT && netinbufpos > 0) { if (pfd[POLL_STDOUT].revents & POLLOUT && netinbufpos > 0) {
ret = drainbuf(pfd[POLL_STDOUT].fd, netinbuf, ret = drainbuf(pfd[POLL_STDOUT].fd, netinbuf,
@ -726,7 +730,7 @@ that are already used by our Debian-specific patches.
pfd[POLL_STDOUT].fd = -1; pfd[POLL_STDOUT].fd = -1;
/* buffer empty - remove self from polling */ /* buffer empty - remove self from polling */
if (netinbufpos == 0) if (netinbufpos == 0)
@@ -1287,19 +1397,29 @@ readwrite(int net_fd, struct tls *tls_ct @@ -1307,21 +1419,31 @@ readwrite(int net_fd, struct tls *tls_ct
} }
ssize_t ssize_t
@ -740,9 +744,11 @@ that are already used by our Debian-specific patches.
ssize_t adjust; ssize_t adjust;
+# if defined(TLS) +# if defined(TLS)
if (tls) if (tls) {
n = tls_write(tls, buf, *bufpos); n = tls_write(tls, buf, *bufpos);
else { if (n == -1)
errx(1, "tls write failed (%s)", tls_error(tls));
} else {
+# endif +# endif
n = write(fd, buf, *bufpos); n = write(fd, buf, *bufpos);
/* don't treat EAGAIN, EINTR as error */ /* don't treat EAGAIN, EINTR as error */
@ -756,7 +762,7 @@ that are already used by our Debian-specific patches.
if (n <= 0) if (n <= 0)
return n; return n;
/* adjust buffer */ /* adjust buffer */
@@ -1311,19 +1431,29 @@ drainbuf(int fd, unsigned char *buf, siz @@ -1333,21 +1455,31 @@ drainbuf(int fd, unsigned char *buf, siz
} }
ssize_t ssize_t
@ -770,9 +776,11 @@ that are already used by our Debian-specific patches.
ssize_t n; ssize_t n;
+# if defined(TLS) +# if defined(TLS)
if (tls) if (tls) {
n = tls_read(tls, buf + *bufpos, num); n = tls_read(tls, buf + *bufpos, num);
else { if (n == -1)
errx(1, "tls read failed (%s)", tls_error(tls));
} else {
+# endif +# endif
n = read(fd, buf + *bufpos, num); n = read(fd, buf + *bufpos, num);
/* don't treat EAGAIN, EINTR as error */ /* don't treat EAGAIN, EINTR as error */
@ -786,7 +794,7 @@ that are already used by our Debian-specific patches.
if (n <= 0) if (n <= 0)
return n; return n;
*bufpos += n; *bufpos += n;
@@ -1641,6 +1771,7 @@ process_tos_opt(char *s, int *val) @@ -1665,6 +1797,7 @@ process_tos_opt(char *s, int *val)
return 0; return 0;
} }
@ -794,15 +802,15 @@ that are already used by our Debian-specific patches.
int int
process_tls_opt(char *s, int *flags) process_tls_opt(char *s, int *flags)
{ {
@@ -1754,6 +1885,7 @@ report_tls(struct tls * tls_ctx, char * @@ -1778,6 +1911,7 @@ report_tls(struct tls * tls_ctx, char *
} }
} }
+# endif +# endif
void void
report_connect(const struct sockaddr *sa, socklen_t salen, char *path) report_sock(const char *msg, const struct sockaddr *sa, socklen_t salen,
@@ -1796,17 +1928,12 @@ help(void) @@ -1816,17 +1950,12 @@ help(void)
fprintf(stderr, "\tCommand Summary:\n\ fprintf(stderr, "\tCommand Summary:\n\
\t-4 Use IPv4\n\ \t-4 Use IPv4\n\
\t-6 Use IPv6\n\ \t-6 Use IPv6\n\
@ -820,7 +828,7 @@ that are already used by our Debian-specific patches.
\t-k Keep inbound sockets open for multiple connects\n\ \t-k Keep inbound sockets open for multiple connects\n\
\t-l Listen mode, for inbound connects\n\ \t-l Listen mode, for inbound connects\n\
\t-M ttl Outgoing TTL / Hop Limit\n\ \t-M ttl Outgoing TTL / Hop Limit\n\
@@ -1814,14 +1941,12 @@ help(void) @@ -1834,14 +1963,12 @@ help(void)
\t-N Shutdown the network socket after EOF on stdin\n\ \t-N Shutdown the network socket after EOF on stdin\n\
\t-n Suppress name/port resolutions\n\ \t-n Suppress name/port resolutions\n\
\t-O length TCP send buffer length\n\ \t-O length TCP send buffer length\n\
@ -836,7 +844,7 @@ that are already used by our Debian-specific patches.
\t-t Answer TELNET negotiation\n\ \t-t Answer TELNET negotiation\n\
\t-U Use UNIX domain socket\n\ \t-U Use UNIX domain socket\n\
\t-u UDP mode\n\ \t-u UDP mode\n\
@@ -1831,7 +1956,6 @@ help(void) @@ -1851,7 +1978,6 @@ help(void)
\t-w timeout Timeout for connects and final net reads\n\ \t-w timeout Timeout for connects and final net reads\n\
\t-X proto Proxy protocol: \"4\", \"5\" (SOCKS) or \"connect\"\n\ \t-X proto Proxy protocol: \"4\", \"5\" (SOCKS) or \"connect\"\n\
\t-x addr[:port]\tSpecify proxy address and port\n\ \t-x addr[:port]\tSpecify proxy address and port\n\
@ -844,7 +852,7 @@ that are already used by our Debian-specific patches.
\t-z Zero-I/O mode [used for scanning]\n\ \t-z Zero-I/O mode [used for scanning]\n\
Port numbers can be individual or ranges: lo-hi [inclusive]\n"); Port numbers can be individual or ranges: lo-hi [inclusive]\n");
exit(0); exit(0);
@@ -1841,15 +1965,11 @@ void @@ -1861,15 +1987,11 @@ void
usage(int ret) usage(int ret)
{ {
fprintf(stderr, fprintf(stderr,

View File

@ -8,8 +8,8 @@ Subject: connect timeout
--- a/netcat.c --- a/netcat.c
+++ b/netcat.c +++ b/netcat.c
@@ -89,6 +89,7 @@ @@ -90,6 +90,7 @@
#include <ctype.h>
#include <err.h> #include <err.h>
#include <errno.h> #include <errno.h>
+#include <fcntl.h> +#include <fcntl.h>
@ -37,7 +37,7 @@ Subject: connect timeout
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
@@ -1066,11 +1074,14 @@ remote_connect(const char *host, const c @@ -1078,11 +1086,14 @@ remote_connect(const char *host, const c
set_common_sockopts(s, res->ai_family); set_common_sockopts(s, res->ai_family);
@ -54,7 +54,7 @@ Subject: connect timeout
save_errno = errno; save_errno = errno;
close(s); close(s);
@@ -1111,6 +1122,69 @@ timeout_connect(int s, const struct sock @@ -1123,6 +1134,69 @@ timeout_connect(int s, const struct sock
return ret; return ret;
} }

View File

@ -29,7 +29,7 @@ Subject: dccp support
Cannot be used together with Cannot be used together with
--- a/netcat.c --- a/netcat.c
+++ b/netcat.c +++ b/netcat.c
@@ -147,6 +147,7 @@ int rflag; /* Random ports flag */ @@ -146,6 +146,7 @@ int rflag; /* Random ports flag */
char *sflag; /* Source Address */ char *sflag; /* Source Address */
int tflag; /* Telnet Emulation */ int tflag; /* Telnet Emulation */
int uflag; /* UDP - Default to TCP */ int uflag; /* UDP - Default to TCP */
@ -37,7 +37,7 @@ Subject: dccp support
int vflag; /* Verbosity */ int vflag; /* Verbosity */
int xflag; /* Socks proxy */ int xflag; /* Socks proxy */
int zflag; /* Port Scan Flag */ int zflag; /* Port Scan Flag */
@@ -225,6 +226,7 @@ ssize_t drainbuf(int, unsigned char *, s @@ -224,6 +225,7 @@ ssize_t drainbuf(int, unsigned char *, s
ssize_t fillbuf(int, unsigned char *, size_t *); ssize_t fillbuf(int, unsigned char *, size_t *);
# endif # endif
@ -45,7 +45,7 @@ Subject: dccp support
static int connect_with_timeout(int fd, const struct sockaddr *sa, static int connect_with_timeout(int fd, const struct sockaddr *sa,
socklen_t salen, int ctimeout); socklen_t salen, int ctimeout);
@@ -261,7 +263,7 @@ main(int argc, char *argv[]) @@ -263,7 +265,7 @@ main(int argc, char *argv[])
# if defined(TLS) # if defined(TLS)
"46C:cDde:FH:hI:i:K:klM:m:NnO:o:P:p:q:R:rSs:T:tUuV:vW:w:X:x:Z:z")) "46C:cDde:FH:hI:i:K:klM:m:NnO:o:P:p:q:R:rSs:T:tUuV:vW:w:X:x:Z:z"))
# else # else
@ -54,7 +54,7 @@ Subject: dccp support
# endif # endif
!= -1) { != -1) {
switch (ch) { switch (ch) {
@@ -378,6 +380,13 @@ main(int argc, char *argv[]) @@ -380,6 +382,13 @@ main(int argc, char *argv[])
case 'u': case 'u':
uflag = 1; uflag = 1;
break; break;
@ -68,7 +68,7 @@ Subject: dccp support
case 'V': case 'V':
# if defined(RT_TABLEID_MAX) # if defined(RT_TABLEID_MAX)
rtableid = (int)strtonum(optarg, 0, rtableid = (int)strtonum(optarg, 0,
@@ -482,6 +491,10 @@ main(int argc, char *argv[]) @@ -484,6 +493,10 @@ main(int argc, char *argv[])
/* Cruft to make sure options are clean, and used properly. */ /* Cruft to make sure options are clean, and used properly. */
if (argv[0] && !argv[1] && family == AF_UNIX) { if (argv[0] && !argv[1] && family == AF_UNIX) {
@ -79,7 +79,7 @@ Subject: dccp support
host = argv[0]; host = argv[0];
uport = NULL; uport = NULL;
} else if (!argv[0] && lflag) { } else if (!argv[0] && lflag) {
@@ -575,8 +588,20 @@ main(int argc, char *argv[]) @@ -577,8 +590,20 @@ main(int argc, char *argv[])
if (family != AF_UNIX) { if (family != AF_UNIX) {
memset(&hints, 0, sizeof(struct addrinfo)); memset(&hints, 0, sizeof(struct addrinfo));
hints.ai_family = family; hints.ai_family = family;
@ -102,7 +102,7 @@ Subject: dccp support
if (nflag) if (nflag)
hints.ai_flags |= AI_NUMERICHOST; hints.ai_flags |= AI_NUMERICHOST;
} }
@@ -584,7 +609,10 @@ main(int argc, char *argv[]) @@ -586,7 +611,10 @@ main(int argc, char *argv[])
if (xflag) { if (xflag) {
if (uflag) if (uflag)
errx(1, "no proxy support for UDP mode"); errx(1, "no proxy support for UDP mode");
@ -114,7 +114,7 @@ Subject: dccp support
if (lflag) if (lflag)
errx(1, "no proxy support for listen"); errx(1, "no proxy support for listen");
@@ -841,19 +869,20 @@ main(int argc, char *argv[]) @@ -833,19 +861,20 @@ main(int argc, char *argv[])
} }
} }
@ -137,7 +137,7 @@ Subject: dccp support
sv ? sv->s_name : "*"); sv ? sv->s_name : "*");
} }
if (Fflag) if (Fflag)
@@ -1063,6 +1092,24 @@ unix_listen(char *path) @@ -1060,6 +1089,24 @@ unix_listen(char *path)
return s; return s;
} }
@ -162,7 +162,7 @@ Subject: dccp support
/* /*
* remote_connect() * remote_connect()
* Returns a socket connected to a remote host. Properly binds to a local * Returns a socket connected to a remote host. Properly binds to a local
@@ -1093,8 +1140,21 @@ remote_connect(const char *host, const c @@ -1090,8 +1137,21 @@ remote_connect(const char *host, const c
# endif # endif
memset(&ahints, 0, sizeof(struct addrinfo)); memset(&ahints, 0, sizeof(struct addrinfo));
ahints.ai_family = res->ai_family; ahints.ai_family = res->ai_family;
@ -186,7 +186,7 @@ Subject: dccp support
ahints.ai_flags = AI_PASSIVE; ahints.ai_flags = AI_PASSIVE;
if ((error = getaddrinfo(sflag, pflag, &ahints, &ares))) if ((error = getaddrinfo(sflag, pflag, &ahints, &ares)))
errx(1, "getaddrinfo: %s", gai_strerror(error)); errx(1, "getaddrinfo: %s", gai_strerror(error));
@@ -1106,15 +1166,16 @@ remote_connect(const char *host, const c @@ -1103,15 +1163,16 @@ remote_connect(const char *host, const c
} }
set_common_sockopts(s, res->ai_family); set_common_sockopts(s, res->ai_family);
@ -206,7 +206,7 @@ Subject: dccp support
save_errno = errno; save_errno = errno;
close(s); close(s);
@@ -1706,7 +1767,8 @@ build_ports(char *p) @@ -1715,7 +1776,8 @@ build_ports(char *p)
int hi, lo, cp; int hi, lo, cp;
int x = 0; int x = 0;
@ -216,7 +216,7 @@ Subject: dccp support
if (sv) { if (sv) {
if (asprintf(&portlist[0], "%d", ntohs(sv->s_port)) < 0) if (asprintf(&portlist[0], "%d", ntohs(sv->s_port)) < 0)
err(1, "asprintf"); err(1, "asprintf");
@@ -2090,6 +2152,7 @@ help(void) @@ -2095,6 +2157,7 @@ help(void)
\t-w timeout Timeout for connects and final net reads\n\ \t-w timeout Timeout for connects and final net reads\n\
\t-X proto Proxy protocol: \"4\", \"5\" (SOCKS) or \"connect\"\n\ \t-X proto Proxy protocol: \"4\", \"5\" (SOCKS) or \"connect\"\n\
\t-x addr[:port]\tSpecify proxy address and port\n\ \t-x addr[:port]\tSpecify proxy address and port\n\
@ -224,7 +224,7 @@ Subject: dccp support
\t-z Zero-I/O mode [used for scanning]\n\ \t-z Zero-I/O mode [used for scanning]\n\
Port numbers can be individual or ranges: lo-hi [inclusive]\n"); Port numbers can be individual or ranges: lo-hi [inclusive]\n");
exit(0); exit(0);
@@ -2099,7 +2162,7 @@ void @@ -2104,7 +2167,7 @@ void
usage(int ret) usage(int ret)
{ {
fprintf(stderr, fprintf(stderr,

View File

@ -50,7 +50,7 @@ Subject: destination port list
is running, and which versions. is running, and which versions.
--- a/netcat.c --- a/netcat.c
+++ b/netcat.c +++ b/netcat.c
@@ -192,7 +192,7 @@ int minttl = -1; @@ -191,7 +191,7 @@ int minttl = -1;
void atelnet(int, unsigned char *, unsigned int); void atelnet(int, unsigned char *, unsigned int);
int strtoport(char *portstr, int udp); int strtoport(char *portstr, int udp);
@ -59,7 +59,7 @@ Subject: destination port list
void help(void) __attribute__((noreturn)); void help(void) __attribute__((noreturn));
int local_listen(const char *, const char *, struct addrinfo); int local_listen(const char *, const char *, struct addrinfo);
# if defined(TLS) # if defined(TLS)
@@ -243,7 +243,7 @@ int @@ -242,7 +242,7 @@ int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
int ch, s = -1, ret, socksv; int ch, s = -1, ret, socksv;
@ -68,7 +68,7 @@ Subject: destination port list
struct addrinfo hints; struct addrinfo hints;
struct servent *sv; struct servent *sv;
socklen_t len; socklen_t len;
@@ -524,11 +524,11 @@ main(int argc, char *argv[]) @@ -526,11 +526,11 @@ main(int argc, char *argv[])
} else if (argv[0] && !argv[1]) { } else if (argv[0] && !argv[1]) {
if (!lflag) if (!lflag)
usage(1); usage(1);
@ -82,7 +82,7 @@ Subject: destination port list
} else } else
usage(1); usage(1);
@@ -715,7 +715,7 @@ main(int argc, char *argv[]) @@ -717,7 +717,7 @@ main(int argc, char *argv[])
else else
s = unix_listen(host); s = unix_listen(host);
} else } else
@ -91,7 +91,7 @@ Subject: destination port list
if (s < 0) if (s < 0)
err(1, NULL); err(1, NULL);
@@ -1775,57 +1775,61 @@ strtoport(char *portstr, int udp) @@ -1785,57 +1785,61 @@ strtoport(char *portstr, int udp)
* that we should try to connect to. * that we should try to connect to.
*/ */
void void
@ -109,7 +109,7 @@ Subject: destination port list
- if (sv) { - if (sv) {
- if (asprintf(&portlist[0], "%d", ntohs(sv->s_port)) < 0) - if (asprintf(&portlist[0], "%d", ntohs(sv->s_port)) < 0)
- err(1, "asprintf"); - err(1, "asprintf");
- } else if ((n = strchr(p, '-')) != NULL) { - } else if (isdigit((unsigned char)*p) && (n = strchr(p, '-')) != NULL) {
- *n = '\0'; - *n = '\0';
- n++; - n++;
- -
@ -138,7 +138,7 @@ Subject: destination port list
+ if (asprintf(&portlist[x], "%d", ntohs(sv->s_port)) < 0) + if (asprintf(&portlist[x], "%d", ntohs(sv->s_port)) < 0)
+ err(1, "asprintf"); + err(1, "asprintf");
+ x++; + x++;
+ } else if ((n = strchr(p[i], '-')) != NULL) { + } else if (isdigit((unsigned char)*p[i]) && (n = strchr(p[i], '-')) != NULL) {
+ *n = '\0'; + *n = '\0';
+ n++; + n++;
+ +

View File

@ -8,7 +8,7 @@ Subject: get sev by name
--- a/netcat.c --- a/netcat.c
+++ b/netcat.c +++ b/netcat.c
@@ -1653,11 +1653,16 @@ strtoport(char *portstr, int udp) @@ -1679,11 +1679,16 @@ strtoport(char *portstr, int udp)
void void
build_ports(char *p) build_ports(char *p)
{ {
@ -17,12 +17,12 @@ Subject: get sev by name
int hi, lo, cp; int hi, lo, cp;
int x = 0; int x = 0;
- if ((n = strchr(p, '-')) != NULL) { - if (isdigit((unsigned char)*p) && (n = strchr(p, '-')) != NULL) {
+ sv = getservbyname(p, uflag ? "udp" : "tcp"); + sv = getservbyname(p, uflag ? "udp" : "tcp");
+ if (sv) { + if (sv) {
+ if (asprintf(&portlist[0], "%d", ntohs(sv->s_port)) < 0) + if (asprintf(&portlist[0], "%d", ntohs(sv->s_port)) < 0)
+ err(1, "asprintf"); + err(1, "asprintf");
+ } else if ((n = strchr(p, '-')) != NULL) { + } else if (isdigit((unsigned char)*p) && (n = strchr(p, '-')) != NULL) {
*n = '\0'; *n = '\0';
n++; n++;

View File

@ -97,7 +97,7 @@ Subject: misc failures and features
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@@ -247,7 +248,10 @@ main(int argc, char *argv[]) @@ -246,7 +247,10 @@ main(int argc, char *argv[])
struct addrinfo hints; struct addrinfo hints;
struct servent *sv; struct servent *sv;
socklen_t len; socklen_t len;
@ -109,7 +109,7 @@ Subject: misc failures and features
char *proxy = NULL, *proxyport = NULL; char *proxy = NULL, *proxyport = NULL;
const char *errstr; const char *errstr;
struct addrinfo proxyhints; struct addrinfo proxyhints;
@@ -952,6 +956,8 @@ unix_bind(char *path, int flags) @@ -945,6 +949,8 @@ unix_bind(char *path, int flags)
0)) < 0) 0)) < 0)
return -1; return -1;
@ -118,7 +118,7 @@ Subject: misc failures and features
memset(&s_un, 0, sizeof(struct sockaddr_un)); memset(&s_un, 0, sizeof(struct sockaddr_un));
s_un.sun_family = AF_UNIX; s_un.sun_family = AF_UNIX;
@@ -1075,8 +1081,10 @@ unix_connect(char *path) @@ -1070,8 +1076,10 @@ unix_connect(char *path)
if ((s = unix_bind(unix_dg_tmp_socket, SOCK_CLOEXEC)) < 0) if ((s = unix_bind(unix_dg_tmp_socket, SOCK_CLOEXEC)) < 0)
return -1; return -1;
} else { } else {
@ -130,7 +130,7 @@ Subject: misc failures and features
} }
memset(&s_un, 0, sizeof(struct sockaddr_un)); memset(&s_un, 0, sizeof(struct sockaddr_un));
@@ -1086,10 +1094,12 @@ unix_connect(char *path) @@ -1081,10 +1089,12 @@ unix_connect(char *path)
sizeof(s_un.sun_path)) { sizeof(s_un.sun_path)) {
close(s); close(s);
errno = ENAMETOOLONG; errno = ENAMETOOLONG;

View File

@ -1,3 +1,24 @@
-------------------------------------------------------------------
Mon Sep 9 18:48:35 UTC 2019 - Tomáš Chvátal <tchvatal@suse.com>
- Update to 1.203 matching debian
- Remove patch verbose-numeric-port.patch
- Refresh patches:
* broadcast-support.patch
* build-without-TLS-support.patch
* connect-timeout.patch
* dccp-support.patch
* destination-port-list.patch
* get-sev-by-name.patch
* misc-failures-and-features.patch
* port-to-linux-with-libsd.patch
* quit-timer.patch
* send-crlf.patch
* serialized-handling-multiple-clients.patch
* set-TCP-MD5SIG-correctly-for-client-connections.patch
* udp-scan-timeout.patch
* use-flags-to-specify-listen-address.patch
------------------------------------------------------------------- -------------------------------------------------------------------
Wed Nov 14 13:12:29 UTC 2018 - Tomáš Chvátal <tchvatal@suse.com> Wed Nov 14 13:12:29 UTC 2018 - Tomáš Chvátal <tchvatal@suse.com>

View File

@ -1,7 +1,7 @@
# #
# spec file for package netcat-openbsd # spec file for package netcat-openbsd
# #
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
# #
# All modifications and additions to the file contributed by third parties # All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed # remain the property of their copyright owners, unless otherwise agreed
@ -17,14 +17,14 @@
Name: netcat-openbsd Name: netcat-openbsd
Version: 1.195 Version: 1.203
Release: 0 Release: 0
Summary: TCP/IP swiss army knife Summary: TCP/IP swiss army knife
License: BSD-3-Clause License: BSD-3-Clause
Group: Productivity/Networking/Other Group: Productivity/Networking/Other
URL: http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/nc/ URL: https://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/nc/
Source0: http://http.debian.net/debian/pool/main/n/netcat-openbsd/netcat-openbsd_%{version}.orig.tar.gz Source0: http://http.debian.net/debian/pool/main/n/netcat-openbsd/netcat-openbsd_%{version}.orig.tar.gz
#Patches from: http://http.debian.net/debian/pool/main/n/netcat-openbsd/netcat-openbsd_%{version}-1.debian.tar.xz #Patches from: http://http.debian.net/debian/pool/main/n/netcat-openbsd/netcat-openbsd_%{version}-2.debian.tar.xz
Patch0: port-to-linux-with-libsd.patch Patch0: port-to-linux-with-libsd.patch
Patch1: build-without-TLS-support.patch Patch1: build-without-TLS-support.patch
Patch2: connect-timeout.patch Patch2: connect-timeout.patch
@ -32,14 +32,13 @@ Patch3: get-sev-by-name.patch
Patch4: send-crlf.patch Patch4: send-crlf.patch
Patch5: quit-timer.patch Patch5: quit-timer.patch
Patch6: udp-scan-timeout.patch Patch6: udp-scan-timeout.patch
Patch7: verbose-numeric-port.patch Patch7: dccp-support.patch
Patch8: dccp-support.patch Patch8: broadcast-support.patch
Patch9: broadcast-support.patch Patch9: serialized-handling-multiple-clients.patch
Patch10: serialized-handling-multiple-clients.patch Patch10: set-TCP-MD5SIG-correctly-for-client-connections.patch
Patch11: set-TCP-MD5SIG-correctly-for-client-connections.patch Patch11: destination-port-list.patch
Patch12: destination-port-list.patch Patch12: use-flags-to-specify-listen-address.patch
Patch13: use-flags-to-specify-listen-address.patch Patch13: misc-failures-and-features.patch
Patch14: misc-failures-and-features.patch
BuildRequires: pkgconfig BuildRequires: pkgconfig
BuildRequires: pkgconfig(libbsd) BuildRequires: pkgconfig(libbsd)
Provides: nc6 = %{version} Provides: nc6 = %{version}

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0e283b2a214313c69447cd962c528ac19afb3ddfe606b25de6d179f187cde4c3
size 22480

BIN
netcat-openbsd_1.203.orig.tar.gz (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -108,9 +108,9 @@ Subject: port to linux with libsd
+#endif /* IPTOS_DSCP_EF */ +#endif /* IPTOS_DSCP_EF */
+ +
#include <ctype.h>
#include <err.h> #include <err.h>
#include <errno.h> @@ -56,6 +101,8 @@
@@ -55,6 +100,8 @@
#include <time.h> #include <time.h>
#include <tls.h> #include <tls.h>
#include <unistd.h> #include <unistd.h>
@ -119,7 +119,7 @@ Subject: port to linux with libsd
#include "atomicio.h" #include "atomicio.h"
@@ -268,10 +315,14 @@ main(int argc, char *argv[]) @@ -269,10 +316,14 @@ main(int argc, char *argv[])
uflag = 1; uflag = 1;
break; break;
case 'V': case 'V':
@ -134,7 +134,7 @@ Subject: port to linux with libsd
break; break;
case 'v': case 'v':
vflag = 1; vflag = 1;
@@ -320,7 +371,11 @@ main(int argc, char *argv[]) @@ -321,7 +372,11 @@ main(int argc, char *argv[])
oflag = optarg; oflag = optarg;
break; break;
case 'S': case 'S':
@ -146,7 +146,7 @@ Subject: port to linux with libsd
break; break;
case 'T': case 'T':
errstr = NULL; errstr = NULL;
@@ -345,14 +400,23 @@ main(int argc, char *argv[]) @@ -346,14 +401,23 @@ main(int argc, char *argv[])
argc -= optind; argc -= optind;
argv += optind; argv += optind;
@ -170,7 +170,7 @@ Subject: port to linux with libsd
} else if (argv[0] && !argv[1]) { } else if (argv[0] && !argv[1]) {
if (!lflag) if (!lflag)
usage(1); usage(1);
@@ -387,33 +451,6 @@ main(int argc, char *argv[]) @@ -388,33 +452,6 @@ main(int argc, char *argv[])
} }
} }
@ -204,7 +204,7 @@ Subject: port to linux with libsd
if (!lflag && kflag) if (!lflag && kflag)
errx(1, "must use -l with -k"); errx(1, "must use -l with -k");
if (uflag && usetls) if (uflag && usetls)
@@ -448,8 +485,8 @@ main(int argc, char *argv[]) @@ -449,8 +486,8 @@ main(int argc, char *argv[])
} else { } else {
strlcpy(unix_dg_tmp_socket_buf, "/tmp/nc.XXXXXXXXXX", strlcpy(unix_dg_tmp_socket_buf, "/tmp/nc.XXXXXXXXXX",
UNIX_DG_TMP_SOCKET_SIZE); UNIX_DG_TMP_SOCKET_SIZE);
@ -215,7 +215,7 @@ Subject: port to linux with libsd
unix_dg_tmp_socket = unix_dg_tmp_socket_buf; unix_dg_tmp_socket = unix_dg_tmp_socket_buf;
} }
} }
@@ -923,8 +960,10 @@ remote_connect(const char *host, const c @@ -933,8 +970,10 @@ remote_connect(const char *host, const c
if (sflag || pflag) { if (sflag || pflag) {
struct addrinfo ahints, *ares; struct addrinfo ahints, *ares;
@ -226,7 +226,7 @@ Subject: port to linux with libsd
memset(&ahints, 0, sizeof(struct addrinfo)); memset(&ahints, 0, sizeof(struct addrinfo));
ahints.ai_family = res->ai_family; ahints.ai_family = res->ai_family;
ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM; ahints.ai_socktype = uflag ? SOCK_DGRAM : SOCK_STREAM;
@@ -1016,9 +1055,15 @@ local_listen(const char *host, const cha @@ -1026,9 +1065,15 @@ local_listen(const char *host, const cha
res->ai_protocol)) < 0) res->ai_protocol)) < 0)
continue; continue;
@ -242,7 +242,7 @@ Subject: port to linux with libsd
set_common_sockopts(s, res->ai_family); set_common_sockopts(s, res->ai_family);
@@ -1474,11 +1519,13 @@ set_common_sockopts(int s, int af) @@ -1498,11 +1543,13 @@ set_common_sockopts(int s, int af)
{ {
int x = 1; int x = 1;
@ -256,7 +256,7 @@ Subject: port to linux with libsd
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)
@@ -1489,9 +1536,14 @@ set_common_sockopts(int s, int af) @@ -1513,9 +1560,14 @@ set_common_sockopts(int s, int af)
IP_TOS, &Tflag, sizeof(Tflag)) == -1) IP_TOS, &Tflag, sizeof(Tflag)) == -1)
err(1, "set IP ToS"); err(1, "set IP ToS");
@ -271,7 +271,7 @@ Subject: port to linux with libsd
} }
if (Iflag) { if (Iflag) {
if (setsockopt(s, SOL_SOCKET, SO_RCVBUF, if (setsockopt(s, SOL_SOCKET, SO_RCVBUF,
@@ -1509,19 +1561,34 @@ set_common_sockopts(int s, int af) @@ -1533,19 +1585,34 @@ set_common_sockopts(int s, int af)
IP_TTL, &ttl, sizeof(ttl))) IP_TTL, &ttl, sizeof(ttl)))
err(1, "set IP TTL"); err(1, "set IP TTL");
@ -306,7 +306,7 @@ Subject: port to linux with libsd
} }
} }
@@ -1556,6 +1623,7 @@ process_tos_opt(char *s, int *val) @@ -1580,6 +1647,7 @@ process_tos_opt(char *s, int *val)
{ "cs7", IPTOS_DSCP_CS7 }, { "cs7", IPTOS_DSCP_CS7 },
{ "ef", IPTOS_DSCP_EF }, { "ef", IPTOS_DSCP_EF },
{ "inetcontrol", IPTOS_PREC_INTERNETCONTROL }, { "inetcontrol", IPTOS_PREC_INTERNETCONTROL },
@ -314,7 +314,7 @@ Subject: port to linux with libsd
{ "lowdelay", IPTOS_LOWDELAY }, { "lowdelay", IPTOS_LOWDELAY },
{ "netcontrol", IPTOS_PREC_NETCONTROL }, { "netcontrol", IPTOS_PREC_NETCONTROL },
{ "reliability", IPTOS_RELIABILITY }, { "reliability", IPTOS_RELIABILITY },
@@ -1721,6 +1789,9 @@ report_connect(const struct sockaddr *sa @@ -1741,6 +1809,9 @@ report_sock(const char *msg, const struc
void void
help(void) help(void)
{ {
@ -324,7 +324,7 @@ Subject: port to linux with libsd
usage(0); usage(0);
fprintf(stderr, "\tCommand Summary:\n\ fprintf(stderr, "\tCommand Summary:\n\
\t-4 Use IPv4\n\ \t-4 Use IPv4\n\
@@ -1763,7 +1834,7 @@ help(void) @@ -1783,7 +1854,7 @@ help(void)
\t-Z Peer certificate file\n\ \t-Z Peer certificate file\n\
\t-z Zero-I/O mode [used for scanning]\n\ \t-z Zero-I/O mode [used for scanning]\n\
Port numbers can be individual or ranges: lo-hi [inclusive]\n"); Port numbers can be individual or ranges: lo-hi [inclusive]\n");

View File

@ -52,7 +52,7 @@ Subject: quit timer
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
@@ -253,9 +256,9 @@ main(int argc, char *argv[]) @@ -256,9 +259,9 @@ main(int argc, char *argv[])
while ((ch = getopt(argc, argv, while ((ch = getopt(argc, argv,
# if defined(TLS) # if defined(TLS)
@ -64,7 +64,7 @@ Subject: quit timer
# endif # endif
!= -1) { != -1) {
switch (ch) { switch (ch) {
@@ -347,6 +350,13 @@ main(int argc, char *argv[]) @@ -350,6 +353,13 @@ main(int argc, char *argv[])
case 'p': case 'p':
pflag = optarg; pflag = optarg;
break; break;
@ -78,7 +78,7 @@ Subject: quit timer
# if defined(TLS) # if defined(TLS)
case 'R': case 'R':
tls_cachanged = 1; tls_cachanged = 1;
@@ -1297,15 +1307,27 @@ readwrite(int net_fd) @@ -1319,15 +1329,27 @@ readwrite(int net_fd)
while (1) { while (1) {
/* both inputs are gone, buffers are empty, we are done */ /* both inputs are gone, buffers are empty, we are done */
if (pfd[POLL_STDIN].fd == -1 && pfd[POLL_NETIN].fd == -1 && if (pfd[POLL_STDIN].fd == -1 && pfd[POLL_NETIN].fd == -1 &&
@ -112,7 +112,7 @@ Subject: quit timer
/* poll */ /* poll */
num_fds = poll(pfd, 4, timeout); num_fds = poll(pfd, 4, timeout);
@@ -2032,6 +2054,7 @@ help(void) @@ -2052,6 +2074,7 @@ help(void)
\t-O length TCP send buffer length\n\ \t-O length TCP send buffer length\n\
\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\
@ -120,7 +120,7 @@ Subject: quit timer
\t-r Randomize remote ports\n\ \t-r Randomize remote ports\n\
\t-S Enable the TCP MD5 signature option\n\ \t-S Enable the TCP MD5 signature option\n\
\t-s source Local source address\n\ \t-s source Local source address\n\
@@ -2056,10 +2079,19 @@ usage(int ret) @@ -2076,10 +2099,19 @@ usage(int ret)
fprintf(stderr, fprintf(stderr,
"usage: nc [-46CDdFhklNnrStUuvz] [-I length] [-i interval] [-M ttl]\n" "usage: nc [-46CDdFhklNnrStUuvz] [-I length] [-i interval] [-M ttl]\n"
"\t [-m minttl] [-O length] [-P proxy_username] [-p source_port]\n" "\t [-m minttl] [-O length] [-P proxy_username] [-p source_port]\n"

View File

@ -3,9 +3,9 @@ Date: Mon, 13 Feb 2012 14:57:45 +0800
Subject: send crlf Subject: send crlf
--- ---
nc.1 | 9 ++++++- nc.1 | 9 +++++--
netcat.c | 72 +++++++++++++++++++++++++++++++++++---------------------------- netcat.c | 74 ++++++++++++++++++++++++++++++++++-----------------------------
2 files changed, 48 insertions(+), 33 deletions(-) 2 files changed, 48 insertions(+), 35 deletions(-)
--- a/nc.1 --- a/nc.1
+++ b/nc.1 +++ b/nc.1
@ -59,7 +59,7 @@ Subject: send crlf
ssize_t fillbuf(int, unsigned char *, size_t *); ssize_t fillbuf(int, unsigned char *, size_t *);
# endif # endif
@@ -253,7 +255,7 @@ main(int argc, char *argv[]) @@ -256,7 +258,7 @@ main(int argc, char *argv[])
# if defined(TLS) # if defined(TLS)
"46C:cDde:FH:hI:i:K:klM:m:NnO:o:P:p:R:rSs:T:tUuV:vW:w:X:x:Z:z")) "46C:cDde:FH:hI:i:K:klM:m:NnO:o:P:p:R:rSs:T:tUuV:vW:w:X:x:Z:z"))
# else # else
@ -68,7 +68,7 @@ Subject: send crlf
# endif # endif
!= -1) { != -1) {
switch (ch) { switch (ch) {
@@ -283,6 +285,10 @@ main(int argc, char *argv[]) @@ -286,6 +288,10 @@ main(int argc, char *argv[])
case 'c': case 'c':
usetls = 1; usetls = 1;
break; break;
@ -79,7 +79,7 @@ Subject: send crlf
# endif # endif
case 'd': case 'd':
dflag = 1; dflag = 1;
@@ -1301,12 +1307,6 @@ readwrite(int net_fd) @@ -1323,12 +1329,6 @@ readwrite(int net_fd)
stdinbufpos == 0 && netinbufpos == 0) stdinbufpos == 0 && netinbufpos == 0)
return; return;
@ -92,7 +92,7 @@ Subject: send crlf
/* poll */ /* poll */
num_fds = poll(pfd, 4, timeout); num_fds = poll(pfd, 4, timeout);
@@ -1386,7 +1386,7 @@ readwrite(int net_fd) @@ -1408,7 +1408,7 @@ readwrite(int net_fd)
pfd[POLL_NETOUT].events = POLLOUT; pfd[POLL_NETOUT].events = POLLOUT;
else else
# else # else
@ -101,7 +101,7 @@ Subject: send crlf
# endif # endif
if (ret == -1) if (ret == -1)
pfd[POLL_NETOUT].fd = -1; pfd[POLL_NETOUT].fd = -1;
@@ -1445,7 +1445,7 @@ readwrite(int net_fd) @@ -1467,7 +1467,7 @@ readwrite(int net_fd)
pfd[POLL_STDOUT].events = POLLOUT; pfd[POLL_STDOUT].events = POLLOUT;
else else
# else # else
@ -110,7 +110,7 @@ Subject: send crlf
# endif # endif
if (ret == -1) if (ret == -1)
pfd[POLL_STDOUT].fd = -1; pfd[POLL_STDOUT].fd = -1;
@@ -1471,31 +1471,40 @@ readwrite(int net_fd) @@ -1493,33 +1493,40 @@ readwrite(int net_fd)
} }
ssize_t ssize_t
@ -127,9 +127,11 @@ Subject: send crlf
+ unsigned char *lf = NULL; + unsigned char *lf = NULL;
-# if defined(TLS) -# if defined(TLS)
- if (tls) - if (tls) {
- n = tls_write(tls, buf, *bufpos); - n = tls_write(tls, buf, *bufpos);
- else { - if (n == -1)
- errx(1, "tls write failed (%s)", tls_error(tls));
- } else {
-# endif -# endif
- n = write(fd, buf, *bufpos); - n = write(fd, buf, *bufpos);
- /* don't treat EAGAIN, EINTR as error */ - /* don't treat EAGAIN, EINTR as error */
@ -171,7 +173,7 @@ Subject: send crlf
/* adjust buffer */ /* adjust buffer */
adjust = *bufpos - n; adjust = *bufpos - n;
if (adjust > 0) if (adjust > 0)
@@ -2007,6 +2016,7 @@ help(void) @@ -2029,6 +2036,7 @@ help(void)
fprintf(stderr, "\tCommand Summary:\n\ fprintf(stderr, "\tCommand Summary:\n\
\t-4 Use IPv4\n\ \t-4 Use IPv4\n\
\t-6 Use IPv6\n\ \t-6 Use IPv6\n\
@ -179,7 +181,7 @@ Subject: send crlf
\t-D Enable the debug socket option\n\ \t-D Enable the debug socket option\n\
\t-d Detach from stdin\n\ \t-d Detach from stdin\n\
\t-F Pass socket fd\n\ \t-F Pass socket fd\n\
@@ -2044,7 +2054,7 @@ void @@ -2066,7 +2074,7 @@ void
usage(int ret) usage(int ret)
{ {
fprintf(stderr, fprintf(stderr,

View File

@ -3,36 +3,24 @@ Date: Tue, 14 Feb 2012 23:02:00 +0800
Subject: serialized handling multiple clients Subject: serialized handling multiple clients
--- ---
netcat.c | 44 +++++++++++++++++++++----------------------- netcat.c | 17 ++++++++---------
1 file changed, 21 insertions(+), 23 deletions(-) 1 file changed, 8 insertions(+), 9 deletions(-)
--- a/netcat.c --- a/netcat.c
+++ b/netcat.c +++ b/netcat.c
@@ -705,6 +705,23 @@ main(int argc, char *argv[]) @@ -707,7 +707,10 @@ main(int argc, char *argv[])
s = unix_bind(host, 0); s = unix_bind(host, 0);
else else
s = unix_listen(host); s = unix_listen(host);
- }
+ } else + } else
+ s = local_listen(host, uport, hints); + s = local_listen(host, uport, hints);
+ if (s < 0) + if (s < 0)
+ err(1, NULL); + err(1, NULL);
+
+ if (vflag && (family != AF_UNIX)) {
+ char* local;
+ if (family == AF_INET)
+ local = "0.0.0.0";
+ else if (family == AF_INET6)
+ local = "::";
+ else
+ local = "unknown";
+ fprintf(stderr, "Listening on [%s] (family %d, port %d)\n",
+ host ?: local,
+ family,
+ *uport);
}
# if defined(TLS) # if defined(TLS)
@@ -719,28 +736,6 @@ main(int argc, char *argv[]) if (usetls) {
@@ -721,13 +724,6 @@ main(int argc, char *argv[])
# endif # endif
/* Allow only one connection at a time, but stay alive. */ /* Allow only one connection at a time, but stay alive. */
for (;;) { for (;;) {
@ -43,25 +31,10 @@ Subject: serialized handling multiple clients
- } - }
- if (s < 0) - if (s < 0)
- err(1, NULL); - err(1, NULL);
-
- if (vflag && (family != AF_UNIX)) {
- char* local;
- if (family == AF_INET)
- local = "0.0.0.0";
- else if (family == AF_INET6)
- local = "::";
- else
- local = "unknown";
- fprintf(stderr, "Listening on [%s] (family %d, port %d)\n",
- host ?: local,
- family,
- *uport);
- }
-
if (uflag && kflag) { if (uflag && kflag) {
/* /*
* For UDP and -k, don't connect the socket, * For UDP and -k, don't connect the socket,
@@ -814,8 +809,11 @@ main(int argc, char *argv[]) @@ -804,8 +800,11 @@ main(int argc, char *argv[])
err(1, "connect"); err(1, "connect");
} }

View File

@ -8,7 +8,7 @@ Subject: Set TCP MD5SIG correctly for client connections
--- a/netcat.c --- a/netcat.c
+++ b/netcat.c +++ b/netcat.c
@@ -47,6 +47,9 @@ @@ -46,6 +46,9 @@
#ifdef __linux__ #ifdef __linux__
# include <linux/in6.h> # include <linux/in6.h>
#endif #endif
@ -18,7 +18,7 @@ Subject: Set TCP MD5SIG correctly for client connections
#ifndef IPTOS_LOWDELAY #ifndef IPTOS_LOWDELAY
# define IPTOS_LOWDELAY 0x10 # define IPTOS_LOWDELAY 0x10
@@ -176,6 +179,9 @@ FILE *Zflag; /* file to save peer ce @@ -175,6 +178,9 @@ FILE *Zflag; /* file to save peer ce
int Cflag = 0; /* CRLF line-ending */ int Cflag = 0; /* CRLF line-ending */
# endif # endif
@ -28,7 +28,7 @@ Subject: Set TCP MD5SIG correctly for client connections
int recvcount, recvlimit; int recvcount, recvlimit;
int timeout = -1; int timeout = -1;
int family = AF_UNSPEC; int family = AF_UNSPEC;
@@ -206,7 +212,7 @@ int udptest(int); @@ -205,7 +211,7 @@ int udptest(int);
int unix_bind(char *, int); int unix_bind(char *, int);
int unix_connect(char *); int unix_connect(char *);
int unix_listen(char *); int unix_listen(char *);
@ -37,7 +37,7 @@ Subject: Set TCP MD5SIG correctly for client connections
int process_tos_opt(char *, int *); int process_tos_opt(char *, int *);
# if defined(TLS) # if defined(TLS)
int process_tls_opt(char *, int *); int process_tls_opt(char *, int *);
@@ -456,7 +462,10 @@ main(int argc, char *argv[]) @@ -458,7 +464,10 @@ main(int argc, char *argv[])
break; break;
# endif # endif
case 'S': case 'S':
@ -49,7 +49,7 @@ Subject: Set TCP MD5SIG correctly for client connections
Sflag = 1; Sflag = 1;
# else # else
errx(1, "no TCP MD5 signature support available"); errx(1, "no TCP MD5 signature support available");
@@ -1171,7 +1180,7 @@ remote_connect(const char *host, const c @@ -1169,7 +1178,7 @@ remote_connect(const char *host, const c
freeaddrinfo(ares); freeaddrinfo(ares);
} }
@ -58,7 +58,7 @@ Subject: Set TCP MD5SIG correctly for client connections
char *proto = proto_name(uflag, dccpflag); char *proto = proto_name(uflag, dccpflag);
if ((error = connect_with_timeout(s, res->ai_addr, res->ai_addrlen, timeout)) == CONNECTION_SUCCESS) if ((error = connect_with_timeout(s, res->ai_addr, res->ai_addrlen, timeout)) == CONNECTION_SUCCESS)
@@ -1325,7 +1334,7 @@ local_listen(const char *host, const cha @@ -1323,7 +1332,7 @@ local_listen(const char *host, const cha
err(1, NULL); err(1, NULL);
# endif # endif
@ -67,7 +67,7 @@ Subject: Set TCP MD5SIG correctly for client connections
if (bind(s, (struct sockaddr *)res->ai_addr, if (bind(s, (struct sockaddr *)res->ai_addr,
res->ai_addrlen) == 0) res->ai_addrlen) == 0)
@@ -1845,9 +1854,10 @@ udptest(int s) @@ -1855,9 +1864,10 @@ udptest(int s)
} }
void void
@ -79,7 +79,7 @@ Subject: Set TCP MD5SIG correctly for client connections
# if defined(SO_BROADCAST) # if defined(SO_BROADCAST)
if (bflag) { if (bflag) {
@@ -1858,10 +1868,17 @@ set_common_sockopts(int s, int af) @@ -1868,10 +1878,17 @@ set_common_sockopts(int s, int af)
err(1, NULL); err(1, NULL);
} }
# endif # endif

View File

@ -17,7 +17,7 @@ Subject: udp scan timeout
/* Command Line Options */ /* Command Line Options */
int dflag; /* detached, no stdin */ int dflag; /* detached, no stdin */
int Fflag; /* fdpass sock to stdout */ int Fflag; /* fdpass sock to stdout */
@@ -815,7 +817,7 @@ main(int argc, char *argv[]) @@ -822,7 +824,7 @@ main(int argc, char *argv[])
continue; continue;
ret = 0; ret = 0;
@ -26,7 +26,7 @@ Subject: udp scan timeout
/* For UDP, make sure we are connected. */ /* For UDP, make sure we are connected. */
if (uflag) { if (uflag) {
if (udptest(s) == -1) { if (udptest(s) == -1) {
@@ -1743,15 +1745,20 @@ build_ports(char *p) @@ -1767,15 +1769,20 @@ build_ports(char *p)
int int
udptest(int s) udptest(int s)
{ {

View File

@ -43,7 +43,7 @@ Subject: use -s/-p flags to specify listen address
Change the IPv4 TOS/IPv6 traffic class value. Change the IPv4 TOS/IPv6 traffic class value.
--- a/netcat.c --- a/netcat.c
+++ b/netcat.c +++ b/netcat.c
@@ -507,31 +507,40 @@ main(int argc, char *argv[]) @@ -509,31 +509,40 @@ main(int argc, char *argv[])
# endif # endif
/* Cruft to make sure options are clean, and used properly. */ /* Cruft to make sure options are clean, and used properly. */
@ -97,7 +97,7 @@ Subject: use -s/-p flags to specify listen address
+ errx(1, "missing socket pathname"); + errx(1, "missing socket pathname");
+ } else if (!uport || !*uport) + } else if (!uport || !*uport)
+ errx(1, "missing port number"); + errx(1, "missing port number");
+ +
+ if (lflag && zflag) + if (lflag && zflag)
+ errx(1, "cannot use -z and -l"); + errx(1, "cannot use -z and -l");
+ +

View File

@ -1,65 +0,0 @@
From: Aron Xu <aron@debian.org>
Date: Mon, 13 Feb 2012 15:38:15 +0800
Subject: verbose numeric port
---
netcat.c | 25 ++++++++++++++++++++-----
1 file changed, 20 insertions(+), 5 deletions(-)
--- a/netcat.c
+++ b/netcat.c
@@ -43,6 +43,7 @@
#include <netinet/tcp.h>
#include <netinet/ip.h>
#include <arpa/telnet.h>
+#include <arpa/inet.h>
#ifdef __linux__
# include <linux/in6.h>
#endif
@@ -689,6 +690,21 @@ main(int argc, char *argv[])
}
if (s < 0)
err(1, NULL);
+
+ if (vflag && (family != AF_UNIX)) {
+ char* local;
+ if (family == AF_INET)
+ local = "0.0.0.0";
+ else if (family == AF_INET6)
+ local = "::";
+ else
+ local = "unknown";
+ fprintf(stderr, "Listening on [%s] (family %d, port %d)\n",
+ host ?: local,
+ family,
+ *uport);
+ }
+
if (uflag && kflag) {
/*
* For UDP and -k, don't connect the socket,
@@ -708,20 +724,19 @@ main(int argc, char *argv[])
*/
int rv;
char buf[2048];
- struct sockaddr_storage z;
- len = sizeof(z);
+ len = sizeof(cliaddr);
rv = recvfrom(s, buf, sizeof(buf), MSG_PEEK,
- (struct sockaddr *)&z, &len);
+ (struct sockaddr *)&cliaddr, &len);
if (rv < 0)
err(1, "recvfrom");
- rv = connect(s, (struct sockaddr *)&z, len);
+ rv = connect(s, (struct sockaddr *)&cliaddr, len);
if (rv < 0)
err(1, "connect");
if (vflag)
- report_connect((struct sockaddr *)&z, len, NULL);
+ report_connect((struct sockaddr *)&cliaddr, len, NULL);
# if defined(TLS)
readwrite(s, NULL);