From d6f10ff5bfe9c80d423515eefe4a87945e9ba69907f462c3f79396ce0bfffbe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= Date: Mon, 9 Sep 2019 18:51:34 +0000 Subject: [PATCH] - 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/package/show/network:utilities/netcat-openbsd?expand=0&rev=20 --- broadcast-support.patch | 10 +- build-without-TLS-support.patch | 128 ++++++++++-------- connect-timeout.patch | 8 +- dccp-support.patch | 28 ++-- destination-port-list.patch | 14 +- get-sev-by-name.patch | 6 +- misc-failures-and-features.patch | 8 +- netcat-openbsd.changes | 21 +++ netcat-openbsd.spec | 23 ++-- netcat-openbsd_1.195.orig.tar.gz | 3 - netcat-openbsd_1.203.orig.tar.gz | 3 + port-to-linux-with-libsd.patch | 30 ++-- quit-timer.patch | 10 +- send-crlf.patch | 28 ++-- serialized-handling-multiple-clients.patch | 41 +----- ...SIG-correctly-for-client-connections.patch | 16 +-- udp-scan-timeout.patch | 4 +- use-flags-to-specify-listen-address.patch | 4 +- verbose-numeric-port.patch | 65 --------- 19 files changed, 194 insertions(+), 256 deletions(-) delete mode 100644 netcat-openbsd_1.195.orig.tar.gz create mode 100644 netcat-openbsd_1.203.orig.tar.gz delete mode 100644 verbose-numeric-port.patch diff --git a/broadcast-support.patch b/broadcast-support.patch index 634b52a..0790f5e 100644 --- a/broadcast-support.patch +++ b/broadcast-support.patch @@ -29,7 +29,7 @@ Subject: broadcast support data is translated into CR+LF before being written to the socket. Line --- a/netcat.c +++ b/netcat.c -@@ -133,6 +133,7 @@ +@@ -132,6 +132,7 @@ #define UDP_SCAN_TIMEOUT 3 /* Seconds */ /* Command Line Options */ @@ -37,7 +37,7 @@ Subject: broadcast support int dflag; /* detached, no stdin */ int Fflag; /* fdpass sock to stdout */ 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, # if defined(TLS) @@ -49,7 +49,7 @@ Subject: broadcast support # endif != -1) { switch (ch) { -@@ -273,6 +274,13 @@ main(int argc, char *argv[]) +@@ -275,6 +276,13 @@ main(int argc, char *argv[]) case '6': family = AF_INET6; break; @@ -63,7 +63,7 @@ Subject: broadcast support case 'U': family = AF_UNIX; 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; @@ -79,7 +79,7 @@ Subject: broadcast support # if defined(TCP_MD5SIG) if (Sflag) { if (setsockopt(s, IPPROTO_TCP, TCP_MD5SIG, -@@ -2122,6 +2139,7 @@ help(void) +@@ -2127,6 +2144,7 @@ help(void) fprintf(stderr, "\tCommand Summary:\n\ \t-4 Use IPv4\n\ \t-6 Use IPv6\n\ diff --git a/build-without-TLS-support.patch b/build-without-TLS-support.patch index 94bf1ee..659d21c 100644 --- a/build-without-TLS-support.patch +++ b/build-without-TLS-support.patch @@ -9,7 +9,7 @@ that are already used by our Debian-specific patches. Makefile | 2 nc.1 | 114 ++--------------------------------------- netcat.c | 172 +++++++++++++++++++++++++++++++++++++++++++++++++++++---------- - 3 files changed, 152 insertions(+), 136 deletions(-) + 3 files changed, 153 insertions(+), 135 deletions(-) --- a/Makefile +++ b/Makefile @@ -232,7 +232,7 @@ that are already used by our Debian-specific patches. .Dl $ nc -u host.example.com 53 --- a/netcat.c +++ b/netcat.c -@@ -98,7 +98,9 @@ +@@ -99,7 +99,9 @@ #include #include #include @@ -243,18 +243,15 @@ that are already used by our Debian-specific patches. #include #include #include -@@ -113,12 +115,14 @@ - #define POLL_NETIN 2 +@@ -115,10 +117,12 @@ #define POLL_STDOUT 3 #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_NONAME (1 << 2) -#define TLS_CCERT (1 << 3) -#define TLS_MUSTSTAPLE (1 << 4) ++#ifdef TLS +# define TLS_NOVERIFY (1 << 1) +# define TLS_NONAME (1 << 2) +# define TLS_CCERT (1 << 3) @@ -269,8 +266,8 @@ that are already used by our Debian-specific patches. +# if defined(TLS) int usetls; /* use TLS */ - char *Cflag; /* Public cert file */ - char *Kflag; /* Private key file */ + const char *Cflag; /* Public cert file */ + const char *Kflag; /* Private key file */ @@ -156,6 +161,7 @@ char *tls_expecthash; /* required hash char *tls_ciphers; /* TLS ciphers */ char *tls_protocols; /* TLS protocols */ @@ -304,7 +301,7 @@ that are already used by our Debian-specific patches. int process_tls_opt(char *, int *); void save_peer_cert(struct tls *_tls_ctx, FILE *_fp); +# endif - void report_connect(const struct sockaddr *, socklen_t, char *); + void report_sock(const char *, const struct sockaddr *, socklen_t, char *); +# if defined(TLS) void report_tls(struct tls *tls_ctx, char * host); +# endif @@ -332,7 +329,14 @@ that are already used by our Debian-specific patches. uint32_t protocols; 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); while ((ch = getopt(argc, argv, @@ -344,7 +348,7 @@ that are already used by our Debian-specific patches. != -1) { switch (ch) { case '4': -@@ -241,24 +268,30 @@ main(int argc, char *argv[]) +@@ -242,24 +271,30 @@ main(int argc, char *argv[]) else errx(1, "unsupported proxy protocol"); break; @@ -375,7 +379,7 @@ that are already used by our Debian-specific patches. case 'h': help(); break; -@@ -267,9 +300,11 @@ main(int argc, char *argv[]) +@@ -268,9 +303,11 @@ main(int argc, char *argv[]) if (errstr) errx(1, "interval %s: %s", errstr, optarg); break; @@ -387,7 +391,7 @@ that are already used by our Debian-specific patches. case 'k': kflag = 1; break; -@@ -298,10 +333,12 @@ main(int argc, char *argv[]) +@@ -299,10 +336,12 @@ main(int argc, char *argv[]) case 'p': pflag = optarg; break; @@ -400,7 +404,7 @@ that are already used by our Debian-specific patches. case 'r': rflag = 1; break; -@@ -343,12 +380,14 @@ main(int argc, char *argv[]) +@@ -344,12 +383,14 @@ main(int argc, char *argv[]) if ((proxy = strdup(optarg)) == NULL) err(1, NULL); break; @@ -415,7 +419,7 @@ that are already used by our Debian-specific patches. case 'z': zflag = 1; 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", errstr, optarg); break; @@ -427,7 +431,7 @@ that are already used by our Debian-specific patches. case 'S': # if defined(TCP_MD5SIG) Sflag = 1; -@@ -380,8 +421,10 @@ main(int argc, char *argv[]) +@@ -381,8 +424,10 @@ main(int argc, char *argv[]) case 'T': errstr = NULL; errno = 0; @@ -438,7 +442,7 @@ that are already used by our Debian-specific patches. if (process_tos_opt(optarg, &Tflag)) break; 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, &errstr); if (Tflag < 0 || Tflag > 255 || errstr || errno) @@ -450,7 +454,7 @@ that are already used by our Debian-specific patches. break; default: usage(1); -@@ -428,6 +475,7 @@ main(int argc, char *argv[]) +@@ -429,6 +478,7 @@ main(int argc, char *argv[]) } else usage(1); @@ -458,7 +462,7 @@ that are already used by our Debian-specific patches. if (usetls) { if (Cflag && unveil(Cflag, "r") == -1) err(1, "unveil"); -@@ -450,15 +498,19 @@ main(int argc, char *argv[]) +@@ -451,15 +501,19 @@ main(int argc, char *argv[]) err(1, "unveil"); } } @@ -478,7 +482,7 @@ that are already used by our Debian-specific patches. if (Fflag && usetls) errx(1, "cannot use -c and -F"); 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"); if (tls_expectname && !usetls) 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 */ 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; } @@ -494,7 +498,7 @@ that are already used by our Debian-specific patches. if (usetls) { if ((tls_cfg = tls_config_new()) == NULL) 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"); } else if (pledge("stdio inet dns", NULL) == -1) err(1, "pledge"); @@ -504,7 +508,7 @@ that are already used by our Debian-specific patches. if (lflag) { ret = 0; -@@ -589,6 +644,7 @@ main(int argc, char *argv[]) +@@ -590,6 +647,7 @@ main(int argc, char *argv[]) s = unix_listen(host); } @@ -512,7 +516,7 @@ that are already used by our Debian-specific patches. if (usetls) { tls_config_verify_client_optional(tls_cfg); 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)", 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. */ for (;;) { 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 * socket pairs. */ @@ -532,9 +536,9 @@ that are already used by our Debian-specific patches. } else if (uflag && !kflag) { /* * For UDP and not -k, we will use recvfrom() -@@ -636,9 +697,14 @@ main(int argc, char *argv[]) - if (vflag) - report_connect((struct sockaddr *)&z, len, NULL); +@@ -638,9 +701,14 @@ main(int argc, char *argv[]) + report_sock("Connection received", + (struct sockaddr *)&z, len, NULL); +# if defined(TLS) readwrite(s, NULL); @@ -547,15 +551,15 @@ that are already used by our Debian-specific patches. int connfd; len = sizeof(cliaddr); -@@ -651,6 +717,7 @@ main(int argc, char *argv[]) - if (vflag) - report_connect((struct sockaddr *)&cliaddr, len, +@@ -654,6 +722,7 @@ main(int argc, char *argv[]) + report_sock("Connection received", + (struct sockaddr *)&cliaddr, len, family == AF_UNIX ? host : NULL); +# if defined(TLS) if ((usetls) && (tls_cctx = tls_setup_server(tls_ctx, connfd, host))) 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); close(connfd); tls_free(tls_cctx); @@ -566,7 +570,7 @@ that are already used by our Debian-specific patches. } if (family == AF_UNIX && uflag) { 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 (!zflag) @@ -576,9 +580,9 @@ that are already used by our Debian-specific patches. + readwrite(s); +# endif close(s); - } else - ret = 1; -@@ -693,6 +768,7 @@ main(int argc, char *argv[]) + } else { + warn("%s", host); +@@ -698,6 +775,7 @@ main(int argc, char *argv[]) for (s = -1, i = 0; portlist[i] != NULL; i++) { if (s != -1) close(s); @@ -586,7 +590,7 @@ that are already used by our Debian-specific patches. tls_free(tls_ctx); 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)", tls_error(tls_ctx)); } @@ -594,7 +598,7 @@ that are already used by our Debian-specific patches. if (xflag) s = socks_connect(host, portlist[i], hints, proxy, proxyport, proxyhints, socksv, -@@ -740,6 +817,7 @@ main(int argc, char *argv[]) +@@ -745,6 +824,7 @@ main(int argc, char *argv[]) } if (Fflag) fdpass(s); @@ -602,7 +606,7 @@ that are already used by our Debian-specific patches. else { if (usetls) 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) timeout_tls(s, tls_ctx, tls_close); } @@ -622,7 +626,7 @@ that are already used by our Debian-specific patches. return ret; } -@@ -794,6 +878,7 @@ unix_bind(char *path, int flags) +@@ -801,6 +887,7 @@ unix_bind(char *path, int flags) return s; } @@ -630,7 +634,7 @@ that are already used by our Debian-specific patches. int 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; } @@ -638,7 +642,7 @@ that are already used by our Debian-specific patches. /* * 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. */ void @@ -650,7 +654,7 @@ that are already used by our Debian-specific patches. { struct pollfd pfd[4]; 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 */ if (pfd[POLL_STDIN].revents & POLLIN && stdinbufpos < BUFSIZE) { 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; /* read something - poll net out */ 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 */ if (pfd[POLL_NETOUT].revents & POLLOUT && stdinbufpos > 0) { 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; /* buffer empty - remove self from polling */ 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 */ if (pfd[POLL_NETIN].revents & POLLIN && netinbufpos < BUFSIZE) { 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; /* eof on net in - remove from pfd */ 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 */ if (pfd[POLL_STDOUT].revents & POLLOUT && netinbufpos > 0) { 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; /* buffer empty - remove self from polling */ 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 @@ -740,9 +744,11 @@ that are already used by our Debian-specific patches. ssize_t adjust; +# if defined(TLS) - if (tls) + if (tls) { n = tls_write(tls, buf, *bufpos); - else { + if (n == -1) + errx(1, "tls write failed (%s)", tls_error(tls)); + } else { +# endif n = write(fd, buf, *bufpos); /* don't treat EAGAIN, EINTR as error */ @@ -756,7 +762,7 @@ that are already used by our Debian-specific patches. if (n <= 0) return n; /* 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 @@ -770,9 +776,11 @@ that are already used by our Debian-specific patches. ssize_t n; +# if defined(TLS) - if (tls) + if (tls) { n = tls_read(tls, buf + *bufpos, num); - else { + if (n == -1) + errx(1, "tls read failed (%s)", tls_error(tls)); + } else { +# endif n = read(fd, buf + *bufpos, num); /* don't treat EAGAIN, EINTR as error */ @@ -786,7 +794,7 @@ that are already used by our Debian-specific patches. if (n <= 0) return 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; } @@ -794,15 +802,15 @@ that are already used by our Debian-specific patches. int 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 void - report_connect(const struct sockaddr *sa, socklen_t salen, char *path) -@@ -1796,17 +1928,12 @@ help(void) + report_sock(const char *msg, const struct sockaddr *sa, socklen_t salen, +@@ -1816,17 +1950,12 @@ help(void) fprintf(stderr, "\tCommand Summary:\n\ \t-4 Use IPv4\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-l Listen mode, for inbound connects\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 Suppress name/port resolutions\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-U Use UNIX domain socket\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-X proto Proxy protocol: \"4\", \"5\" (SOCKS) or \"connect\"\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\ Port numbers can be individual or ranges: lo-hi [inclusive]\n"); exit(0); -@@ -1841,15 +1965,11 @@ void +@@ -1861,15 +1987,11 @@ void usage(int ret) { fprintf(stderr, diff --git a/connect-timeout.patch b/connect-timeout.patch index 38d0134..fd40ff5 100644 --- a/connect-timeout.patch +++ b/connect-timeout.patch @@ -8,8 +8,8 @@ Subject: connect timeout --- a/netcat.c +++ b/netcat.c -@@ -89,6 +89,7 @@ - +@@ -90,6 +90,7 @@ + #include #include #include +#include @@ -37,7 +37,7 @@ Subject: connect timeout int 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); @@ -54,7 +54,7 @@ Subject: connect timeout save_errno = errno; 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; } diff --git a/dccp-support.patch b/dccp-support.patch index 17587b3..56b6def 100644 --- a/dccp-support.patch +++ b/dccp-support.patch @@ -29,7 +29,7 @@ Subject: dccp support Cannot be used together with --- a/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 */ int tflag; /* Telnet Emulation */ int uflag; /* UDP - Default to TCP */ @@ -37,7 +37,7 @@ Subject: dccp support int vflag; /* Verbosity */ int xflag; /* Socks proxy */ 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 *); # endif @@ -45,7 +45,7 @@ Subject: dccp support static int connect_with_timeout(int fd, const struct sockaddr *sa, 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) "46C:cDde:FH:hI:i:K:klM:m:NnO:o:P:p:q:R:rSs:T:tUuV:vW:w:X:x:Z:z")) # else @@ -54,7 +54,7 @@ Subject: dccp support # endif != -1) { switch (ch) { -@@ -378,6 +380,13 @@ main(int argc, char *argv[]) +@@ -380,6 +382,13 @@ main(int argc, char *argv[]) case 'u': uflag = 1; break; @@ -68,7 +68,7 @@ Subject: dccp support case 'V': # if defined(RT_TABLEID_MAX) 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. */ if (argv[0] && !argv[1] && family == AF_UNIX) { @@ -79,7 +79,7 @@ Subject: dccp support host = argv[0]; uport = NULL; } 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) { memset(&hints, 0, sizeof(struct addrinfo)); hints.ai_family = family; @@ -102,7 +102,7 @@ Subject: dccp support if (nflag) 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 (uflag) errx(1, "no proxy support for UDP mode"); @@ -114,7 +114,7 @@ Subject: dccp support if (lflag) 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 : "*"); } if (Fflag) -@@ -1063,6 +1092,24 @@ unix_listen(char *path) +@@ -1060,6 +1089,24 @@ unix_listen(char *path) return s; } @@ -162,7 +162,7 @@ Subject: dccp support /* * remote_connect() * 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 memset(&ahints, 0, sizeof(struct addrinfo)); ahints.ai_family = res->ai_family; @@ -186,7 +186,7 @@ Subject: dccp support ahints.ai_flags = AI_PASSIVE; if ((error = getaddrinfo(sflag, pflag, &ahints, &ares))) 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); @@ -206,7 +206,7 @@ Subject: dccp support save_errno = errno; close(s); -@@ -1706,7 +1767,8 @@ build_ports(char *p) +@@ -1715,7 +1776,8 @@ build_ports(char *p) int hi, lo, cp; int x = 0; @@ -216,7 +216,7 @@ Subject: dccp support if (sv) { if (asprintf(&portlist[0], "%d", ntohs(sv->s_port)) < 0) 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-X proto Proxy protocol: \"4\", \"5\" (SOCKS) or \"connect\"\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\ Port numbers can be individual or ranges: lo-hi [inclusive]\n"); exit(0); -@@ -2099,7 +2162,7 @@ void +@@ -2104,7 +2167,7 @@ void usage(int ret) { fprintf(stderr, diff --git a/destination-port-list.patch b/destination-port-list.patch index d6d1812..a9fe28f 100644 --- a/destination-port-list.patch +++ b/destination-port-list.patch @@ -50,7 +50,7 @@ Subject: destination port list is running, and which versions. --- a/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); int strtoport(char *portstr, int udp); @@ -59,7 +59,7 @@ Subject: destination port list void help(void) __attribute__((noreturn)); int local_listen(const char *, const char *, struct addrinfo); # if defined(TLS) -@@ -243,7 +243,7 @@ int +@@ -242,7 +242,7 @@ int main(int argc, char *argv[]) { int ch, s = -1, ret, socksv; @@ -68,7 +68,7 @@ Subject: destination port list struct addrinfo hints; struct servent *sv; 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]) { if (!lflag) usage(1); @@ -82,7 +82,7 @@ Subject: destination port list } else usage(1); -@@ -715,7 +715,7 @@ main(int argc, char *argv[]) +@@ -717,7 +717,7 @@ main(int argc, char *argv[]) else s = unix_listen(host); } else @@ -91,7 +91,7 @@ Subject: destination port list if (s < 0) 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. */ void @@ -109,7 +109,7 @@ Subject: destination port list - if (sv) { - if (asprintf(&portlist[0], "%d", ntohs(sv->s_port)) < 0) - err(1, "asprintf"); -- } else if ((n = strchr(p, '-')) != NULL) { +- } else if (isdigit((unsigned char)*p) && (n = strchr(p, '-')) != NULL) { - *n = '\0'; - n++; - @@ -138,7 +138,7 @@ Subject: destination port list + if (asprintf(&portlist[x], "%d", ntohs(sv->s_port)) < 0) + err(1, "asprintf"); + x++; -+ } else if ((n = strchr(p[i], '-')) != NULL) { ++ } else if (isdigit((unsigned char)*p[i]) && (n = strchr(p[i], '-')) != NULL) { + *n = '\0'; + n++; + diff --git a/get-sev-by-name.patch b/get-sev-by-name.patch index a49b568..701788c 100644 --- a/get-sev-by-name.patch +++ b/get-sev-by-name.patch @@ -8,7 +8,7 @@ Subject: get sev by name --- a/netcat.c +++ b/netcat.c -@@ -1653,11 +1653,16 @@ strtoport(char *portstr, int udp) +@@ -1679,11 +1679,16 @@ strtoport(char *portstr, int udp) void build_ports(char *p) { @@ -17,12 +17,12 @@ Subject: get sev by name int hi, lo, cp; int x = 0; -- if ((n = strchr(p, '-')) != NULL) { +- if (isdigit((unsigned char)*p) && (n = strchr(p, '-')) != NULL) { + sv = getservbyname(p, uflag ? "udp" : "tcp"); + if (sv) { + if (asprintf(&portlist[0], "%d", ntohs(sv->s_port)) < 0) + err(1, "asprintf"); -+ } else if ((n = strchr(p, '-')) != NULL) { ++ } else if (isdigit((unsigned char)*p) && (n = strchr(p, '-')) != NULL) { *n = '\0'; n++; diff --git a/misc-failures-and-features.patch b/misc-failures-and-features.patch index 9ddcc0c..e48e095 100644 --- a/misc-failures-and-features.patch +++ b/misc-failures-and-features.patch @@ -97,7 +97,7 @@ Subject: misc failures and features #include #include #include -@@ -247,7 +248,10 @@ main(int argc, char *argv[]) +@@ -246,7 +247,10 @@ main(int argc, char *argv[]) struct addrinfo hints; struct servent *sv; socklen_t len; @@ -109,7 +109,7 @@ Subject: misc failures and features char *proxy = NULL, *proxyport = NULL; const char *errstr; 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) return -1; @@ -118,7 +118,7 @@ Subject: misc failures and features memset(&s_un, 0, sizeof(struct sockaddr_un)); 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) return -1; } else { @@ -130,7 +130,7 @@ Subject: misc failures and features } 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)) { close(s); errno = ENAMETOOLONG; diff --git a/netcat-openbsd.changes b/netcat-openbsd.changes index 2175559..b9c2dd9 100644 --- a/netcat-openbsd.changes +++ b/netcat-openbsd.changes @@ -1,3 +1,24 @@ +------------------------------------------------------------------- +Mon Sep 9 18:48:35 UTC 2019 - Tomáš Chvátal + +- 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 diff --git a/netcat-openbsd.spec b/netcat-openbsd.spec index 8332c1f..347bd50 100644 --- a/netcat-openbsd.spec +++ b/netcat-openbsd.spec @@ -1,7 +1,7 @@ # # 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 # remain the property of their copyright owners, unless otherwise agreed @@ -17,14 +17,14 @@ Name: netcat-openbsd -Version: 1.195 +Version: 1.203 Release: 0 Summary: TCP/IP swiss army knife License: BSD-3-Clause 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 -#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 Patch1: build-without-TLS-support.patch Patch2: connect-timeout.patch @@ -32,14 +32,13 @@ Patch3: get-sev-by-name.patch Patch4: send-crlf.patch Patch5: quit-timer.patch Patch6: udp-scan-timeout.patch -Patch7: verbose-numeric-port.patch -Patch8: dccp-support.patch -Patch9: broadcast-support.patch -Patch10: serialized-handling-multiple-clients.patch -Patch11: set-TCP-MD5SIG-correctly-for-client-connections.patch -Patch12: destination-port-list.patch -Patch13: use-flags-to-specify-listen-address.patch -Patch14: misc-failures-and-features.patch +Patch7: dccp-support.patch +Patch8: broadcast-support.patch +Patch9: serialized-handling-multiple-clients.patch +Patch10: set-TCP-MD5SIG-correctly-for-client-connections.patch +Patch11: destination-port-list.patch +Patch12: use-flags-to-specify-listen-address.patch +Patch13: misc-failures-and-features.patch BuildRequires: pkgconfig BuildRequires: pkgconfig(libbsd) Provides: nc6 = %{version} diff --git a/netcat-openbsd_1.195.orig.tar.gz b/netcat-openbsd_1.195.orig.tar.gz deleted file mode 100644 index 6d544d9..0000000 --- a/netcat-openbsd_1.195.orig.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:0e283b2a214313c69447cd962c528ac19afb3ddfe606b25de6d179f187cde4c3 -size 22480 diff --git a/netcat-openbsd_1.203.orig.tar.gz b/netcat-openbsd_1.203.orig.tar.gz new file mode 100644 index 0000000..676252f --- /dev/null +++ b/netcat-openbsd_1.203.orig.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b025399f1588da78108290a721157be66871b096bc9c3973ebdc8d773f750a3f +size 22574 diff --git a/port-to-linux-with-libsd.patch b/port-to-linux-with-libsd.patch index 3c53956..13e3f22 100644 --- a/port-to-linux-with-libsd.patch +++ b/port-to-linux-with-libsd.patch @@ -108,9 +108,9 @@ Subject: port to linux with libsd +#endif /* IPTOS_DSCP_EF */ + + #include #include - #include -@@ -55,6 +100,8 @@ +@@ -56,6 +101,8 @@ #include #include #include @@ -119,7 +119,7 @@ Subject: port to linux with libsd #include "atomicio.h" -@@ -268,10 +315,14 @@ main(int argc, char *argv[]) +@@ -269,10 +316,14 @@ main(int argc, char *argv[]) uflag = 1; break; case 'V': @@ -134,7 +134,7 @@ Subject: port to linux with libsd break; case 'v': vflag = 1; -@@ -320,7 +371,11 @@ main(int argc, char *argv[]) +@@ -321,7 +372,11 @@ main(int argc, char *argv[]) oflag = optarg; break; case 'S': @@ -146,7 +146,7 @@ Subject: port to linux with libsd break; case 'T': errstr = NULL; -@@ -345,14 +400,23 @@ main(int argc, char *argv[]) +@@ -346,14 +401,23 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; @@ -170,7 +170,7 @@ Subject: port to linux with libsd } else if (argv[0] && !argv[1]) { if (!lflag) 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) errx(1, "must use -l with -k"); if (uflag && usetls) -@@ -448,8 +485,8 @@ main(int argc, char *argv[]) +@@ -449,8 +486,8 @@ main(int argc, char *argv[]) } else { strlcpy(unix_dg_tmp_socket_buf, "/tmp/nc.XXXXXXXXXX", UNIX_DG_TMP_SOCKET_SIZE); @@ -215,7 +215,7 @@ Subject: port to linux with libsd 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) { struct addrinfo ahints, *ares; @@ -226,7 +226,7 @@ Subject: port to linux with libsd memset(&ahints, 0, sizeof(struct addrinfo)); ahints.ai_family = res->ai_family; 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) continue; @@ -242,7 +242,7 @@ Subject: port to linux with libsd 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; @@ -256,7 +256,7 @@ Subject: port to linux with libsd if (Dflag) { if (setsockopt(s, SOL_SOCKET, SO_DEBUG, &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) err(1, "set IP ToS"); @@ -271,7 +271,7 @@ Subject: port to linux with libsd } if (Iflag) { 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))) 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 }, { "ef", IPTOS_DSCP_EF }, { "inetcontrol", IPTOS_PREC_INTERNETCONTROL }, @@ -314,7 +314,7 @@ Subject: port to linux with libsd { "lowdelay", IPTOS_LOWDELAY }, { "netcontrol", IPTOS_PREC_NETCONTROL }, { "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 help(void) { @@ -324,7 +324,7 @@ Subject: port to linux with libsd usage(0); fprintf(stderr, "\tCommand Summary:\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 Zero-I/O mode [used for scanning]\n\ Port numbers can be individual or ranges: lo-hi [inclusive]\n"); diff --git a/quit-timer.patch b/quit-timer.patch index dd01347..ab4391c 100644 --- a/quit-timer.patch +++ b/quit-timer.patch @@ -52,7 +52,7 @@ Subject: quit timer int 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, # if defined(TLS) @@ -64,7 +64,7 @@ Subject: quit timer # endif != -1) { switch (ch) { -@@ -347,6 +350,13 @@ main(int argc, char *argv[]) +@@ -350,6 +353,13 @@ main(int argc, char *argv[]) case 'p': pflag = optarg; break; @@ -78,7 +78,7 @@ Subject: quit timer # if defined(TLS) case 'R': tls_cachanged = 1; -@@ -1297,15 +1307,27 @@ readwrite(int net_fd) +@@ -1319,15 +1329,27 @@ readwrite(int net_fd) while (1) { /* both inputs are gone, buffers are empty, we are done */ if (pfd[POLL_STDIN].fd == -1 && pfd[POLL_NETIN].fd == -1 && @@ -112,7 +112,7 @@ Subject: quit timer /* poll */ 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-P proxyuser\tUsername for proxy authentication\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-S Enable the TCP MD5 signature option\n\ \t-s source Local source address\n\ -@@ -2056,10 +2079,19 @@ usage(int ret) +@@ -2076,10 +2099,19 @@ usage(int ret) fprintf(stderr, "usage: nc [-46CDdFhklNnrStUuvz] [-I length] [-i interval] [-M ttl]\n" "\t [-m minttl] [-O length] [-P proxy_username] [-p source_port]\n" diff --git a/send-crlf.patch b/send-crlf.patch index cda2695..fef91d2 100644 --- a/send-crlf.patch +++ b/send-crlf.patch @@ -3,9 +3,9 @@ Date: Mon, 13 Feb 2012 14:57:45 +0800 Subject: send crlf --- - nc.1 | 9 ++++++- - netcat.c | 72 +++++++++++++++++++++++++++++++++++---------------------------- - 2 files changed, 48 insertions(+), 33 deletions(-) + nc.1 | 9 +++++-- + netcat.c | 74 ++++++++++++++++++++++++++++++++++----------------------------- + 2 files changed, 48 insertions(+), 35 deletions(-) --- a/nc.1 +++ b/nc.1 @@ -59,7 +59,7 @@ Subject: send crlf ssize_t fillbuf(int, unsigned char *, size_t *); # endif -@@ -253,7 +255,7 @@ main(int argc, char *argv[]) +@@ -256,7 +258,7 @@ main(int argc, char *argv[]) # 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")) # else @@ -68,7 +68,7 @@ Subject: send crlf # endif != -1) { switch (ch) { -@@ -283,6 +285,10 @@ main(int argc, char *argv[]) +@@ -286,6 +288,10 @@ main(int argc, char *argv[]) case 'c': usetls = 1; break; @@ -79,7 +79,7 @@ Subject: send crlf # endif case 'd': dflag = 1; -@@ -1301,12 +1307,6 @@ readwrite(int net_fd) +@@ -1323,12 +1329,6 @@ readwrite(int net_fd) stdinbufpos == 0 && netinbufpos == 0) return; @@ -92,7 +92,7 @@ Subject: send crlf /* poll */ 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; else # else @@ -101,7 +101,7 @@ Subject: send crlf # endif if (ret == -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; else # else @@ -110,7 +110,7 @@ Subject: send crlf # endif if (ret == -1) pfd[POLL_STDOUT].fd = -1; -@@ -1471,31 +1471,40 @@ readwrite(int net_fd) +@@ -1493,33 +1493,40 @@ readwrite(int net_fd) } ssize_t @@ -127,9 +127,11 @@ Subject: send crlf + unsigned char *lf = NULL; -# if defined(TLS) -- if (tls) +- if (tls) { - n = tls_write(tls, buf, *bufpos); -- else { +- if (n == -1) +- errx(1, "tls write failed (%s)", tls_error(tls)); +- } else { -# endif - n = write(fd, buf, *bufpos); - /* don't treat EAGAIN, EINTR as error */ @@ -171,7 +173,7 @@ Subject: send crlf /* adjust buffer */ adjust = *bufpos - n; if (adjust > 0) -@@ -2007,6 +2016,7 @@ help(void) +@@ -2029,6 +2036,7 @@ help(void) fprintf(stderr, "\tCommand Summary:\n\ \t-4 Use IPv4\n\ \t-6 Use IPv6\n\ @@ -179,7 +181,7 @@ Subject: send crlf \t-D Enable the debug socket option\n\ \t-d Detach from stdin\n\ \t-F Pass socket fd\n\ -@@ -2044,7 +2054,7 @@ void +@@ -2066,7 +2074,7 @@ void usage(int ret) { fprintf(stderr, diff --git a/serialized-handling-multiple-clients.patch b/serialized-handling-multiple-clients.patch index 6ef95b2..24929b4 100644 --- a/serialized-handling-multiple-clients.patch +++ b/serialized-handling-multiple-clients.patch @@ -3,36 +3,24 @@ Date: Tue, 14 Feb 2012 23:02:00 +0800 Subject: serialized handling multiple clients --- - netcat.c | 44 +++++++++++++++++++++----------------------- - 1 file changed, 21 insertions(+), 23 deletions(-) + netcat.c | 17 ++++++++--------- + 1 file changed, 8 insertions(+), 9 deletions(-) --- a/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); else s = unix_listen(host); +- } + } else + s = local_listen(host, uport, hints); + 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 defined(TLS) -@@ -719,28 +736,6 @@ main(int argc, char *argv[]) + if (usetls) { +@@ -721,13 +724,6 @@ main(int argc, char *argv[]) # endif /* Allow only one connection at a time, but stay alive. */ for (;;) { @@ -43,25 +31,10 @@ Subject: serialized handling multiple clients - } - 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, -@@ -814,8 +809,11 @@ main(int argc, char *argv[]) +@@ -804,8 +800,11 @@ main(int argc, char *argv[]) err(1, "connect"); } diff --git a/set-TCP-MD5SIG-correctly-for-client-connections.patch b/set-TCP-MD5SIG-correctly-for-client-connections.patch index c8b0d00..d9e0b84 100644 --- a/set-TCP-MD5SIG-correctly-for-client-connections.patch +++ b/set-TCP-MD5SIG-correctly-for-client-connections.patch @@ -8,7 +8,7 @@ Subject: Set TCP MD5SIG correctly for client connections --- a/netcat.c +++ b/netcat.c -@@ -47,6 +47,9 @@ +@@ -46,6 +46,9 @@ #ifdef __linux__ # include #endif @@ -18,7 +18,7 @@ Subject: Set TCP MD5SIG correctly for client connections #ifndef IPTOS_LOWDELAY # 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 */ # endif @@ -28,7 +28,7 @@ Subject: Set TCP MD5SIG correctly for client connections int recvcount, recvlimit; int timeout = -1; 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_connect(char *); int unix_listen(char *); @@ -37,7 +37,7 @@ Subject: Set TCP MD5SIG correctly for client connections int process_tos_opt(char *, int *); # if defined(TLS) 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; # endif case 'S': @@ -49,7 +49,7 @@ Subject: Set TCP MD5SIG correctly for client connections Sflag = 1; # else 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); } @@ -58,7 +58,7 @@ Subject: Set TCP MD5SIG correctly for client connections char *proto = proto_name(uflag, dccpflag); 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); # endif @@ -67,7 +67,7 @@ Subject: Set TCP MD5SIG correctly for client connections if (bind(s, (struct sockaddr *)res->ai_addr, res->ai_addrlen) == 0) -@@ -1845,9 +1854,10 @@ udptest(int s) +@@ -1855,9 +1864,10 @@ udptest(int s) } void @@ -79,7 +79,7 @@ Subject: Set TCP MD5SIG correctly for client connections # if defined(SO_BROADCAST) 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); } # endif diff --git a/udp-scan-timeout.patch b/udp-scan-timeout.patch index 8ef539c..ccaf510 100644 --- a/udp-scan-timeout.patch +++ b/udp-scan-timeout.patch @@ -17,7 +17,7 @@ Subject: udp scan timeout /* Command Line Options */ int dflag; /* detached, no stdin */ 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; ret = 0; @@ -26,7 +26,7 @@ Subject: udp scan timeout /* For UDP, make sure we are connected. */ if (uflag) { if (udptest(s) == -1) { -@@ -1743,15 +1745,20 @@ build_ports(char *p) +@@ -1767,15 +1769,20 @@ build_ports(char *p) int udptest(int s) { diff --git a/use-flags-to-specify-listen-address.patch b/use-flags-to-specify-listen-address.patch index 5e6703d..e612128 100644 --- a/use-flags-to-specify-listen-address.patch +++ b/use-flags-to-specify-listen-address.patch @@ -43,7 +43,7 @@ Subject: use -s/-p flags to specify listen address Change the IPv4 TOS/IPv6 traffic class value. --- a/netcat.c +++ b/netcat.c -@@ -507,31 +507,40 @@ main(int argc, char *argv[]) +@@ -509,31 +509,40 @@ main(int argc, char *argv[]) # endif /* 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"); + } else if (!uport || !*uport) + errx(1, "missing port number"); -+ ++ + if (lflag && zflag) + errx(1, "cannot use -z and -l"); + diff --git a/verbose-numeric-port.patch b/verbose-numeric-port.patch deleted file mode 100644 index 9d73242..0000000 --- a/verbose-numeric-port.patch +++ /dev/null @@ -1,65 +0,0 @@ -From: Aron Xu -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 - #include - #include -+#include - #ifdef __linux__ - # include - #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);