[Slackbuilds-users] [PATCH netcat-openbsd 1/1] Fix zero seconds quit

Duncan Roe duncan_roe at optusnet.com.au
Mon Jan 13 02:56:29 UTC 2020


Patch 0006-quit-timer.patch introduced -q <secs> for nc to exit after EOF on
stdin. However it used the same variable as a flag (-q option present) and a
value (number of seconds to wait) so that -q 0 had no effect rather than causing
immediate exit on EOF as the documentation implied it should.

Have separate qflag and qval to fix.

Signed-off-by: Duncan Roe <duncan_roe at optusnet.com.au>
---
 network/netcat-openbsd/netcat-openbsd.SlackBuild   |  2 +-
 .../netcat-openbsd/patches/SB-zero-secs-quit.patch | 34 ++++++++++++++++++++++
 2 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 network/netcat-openbsd/patches/SB-zero-secs-quit.patch

diff --git a/network/netcat-openbsd/netcat-openbsd.SlackBuild b/network/netcat-openbsd/netcat-openbsd.SlackBuild
index c807a163db..a63707a4bf 100644
--- a/network/netcat-openbsd/netcat-openbsd.SlackBuild
+++ b/network/netcat-openbsd/netcat-openbsd.SlackBuild
@@ -24,7 +24,7 @@
 
 PRGNAM=netcat-openbsd
 VERSION=${VERSION:-1.105}
-BUILD=${BUILD:-2}
+BUILD=${BUILD:-3}
 TAG=${TAG:-_SBo}
 
 DEBVER=7
diff --git a/network/netcat-openbsd/patches/SB-zero-secs-quit.patch b/network/netcat-openbsd/patches/SB-zero-secs-quit.patch
new file mode 100644
index 0000000000..f80e4d5ec9
--- /dev/null
+++ b/network/netcat-openbsd/patches/SB-zero-secs-quit.patch
@@ -0,0 +1,34 @@
+# This patch enables nc -q 0 to immediately exit on stdin EOF.# This was already the documented behaviour.--- netcat.c	2020/01/12 01:10:58	1.1
++++ a/netcat.c	2020/01/12 04:22:20	1.4
+@@ -127,6 +127,7 @@
+ char   *Pflag;					/* Proxy username */
+ char   *pflag;					/* Localport flag */
+ int     qflag = 0;                             /* Quit after some secs */
++int     qval = 0;                              /* # secs to wait for quit */
+ int	rflag;					/* Random ports flag */
+ char   *sflag;					/* Source Address */
+ int	tflag;					/* Telnet Emulation */
+@@ -256,7 +257,8 @@
+ 			pflag = optarg;
+ 			break;
+                 case 'q':
+-			qflag = strtonum(optarg, INT_MIN, INT_MAX, &errstr);
++			qflag = 1;
++			qval = strtonum(optarg, INT_MIN, INT_MAX, &errstr);
+ 			if (errstr)
+ 				errx(1, "quit timer %s: %s", errstr, optarg);
+ 			break;
+@@ -1089,9 +1091,11 @@
+ 				close(wfd);
+ 			}
+ 			/* if user asked to die after a while, arrange for it */
+-			if (qflag > 0) {
++			if (qval == 0)
++				exit(0);
++			if (qval > 0) {
+ 				signal(SIGALRM, quit);
+-				alarm(qflag);
++				alarm(qval);
+ 			}
+ 			pfd[1].fd = -1;
+ 			pfd[1].events = 0;
-- 
2.14.5



More information about the SlackBuilds-users mailing list