unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
blob 61cd07994befa12e16f8dcbf08db8172c9b018cf 1480 bytes (raw)
name: gnu/packages/patches/netcat-openbsd-0007-udp-scan-timeout.patch 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
 
This patch is based on db2b1d9a8d4644ef892f47d84606ee96598d23fb
of http://anonscm.debian.org/cgit/collab-maint/netcat-openbsd.git

From: Aron Xu <aron@debian.org>
Date: Mon, 13 Feb 2012 15:29:37 +0800
Subject: udp scan timeout

---
 netcat.c |   25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/netcat.c b/netcat.c
index 29ecf1a..baab909 100644
--- a/netcat.c
+++ b/netcat.c
@@ -111,6 +111,8 @@
 #define CONNECTION_FAILED 1
 #define CONNECTION_TIMEOUT 2

+#define UDP_SCAN_TIMEOUT 3			/* Seconds */
+
 /* Command Line Options */
 int     Cflag = 0;                              /* CRLF line-ending */
 int	dflag;					/* detached, no stdin */
@@ -497,7 +499,7 @@ main(int argc, char *argv[])
 				continue;

 			ret = 0;
-			if (vflag || zflag) {
+			if (vflag) {
 				/* For UDP, make sure we are connected. */
 				if (uflag) {
 					if (udptest(s) == -1) {
@@ -1057,15 +1059,20 @@ build_ports(char *p)
 int
 udptest(int s)
 {
-	int i, ret;
-
-	for (i = 0; i <= 3; i++) {
-		if (write(s, "X", 1) == 1)
-			ret = 1;
-		else
-			ret = -1;
+	int i, t;
+
+	if ((write(s, "X", 1) != 1) ||
+	    ((write(s, "X", 1) != 1) && (errno == ECONNREFUSED)))
+		return -1;
+
+	/* Give the remote host some time to reply. */
+	for (i = 0, t = (timeout == -1) ? UDP_SCAN_TIMEOUT : (timeout / 1000);
+	     i < t; i++) {
+		sleep(1);
+		if ((write(s, "X", 1) != 1) && (errno == ECONNREFUSED))
+			return -1;
 	}
-	return (ret);
+	return 1;
 }

 void
--

debug log:

solving 61cd079 ...
found 61cd079 in https://yhetil.org/guix-devel/20160622110046.GA12755@shadowwalker/

applying [1/1] https://yhetil.org/guix-devel/20160622110046.GA12755@shadowwalker/
diff --git a/gnu/packages/patches/netcat-openbsd-0007-udp-scan-timeout.patch b/gnu/packages/patches/netcat-openbsd-0007-udp-scan-timeout.patch
new file mode 100644
index 0000000..61cd079

1:32: space before tab in indent.
 				continue;
1:34: space before tab in indent.
 			ret = 0;
1:37: space before tab in indent.
 				/* For UDP, make sure we are connected. */
1:38: space before tab in indent.
 				if (uflag) {
1:39: space before tab in indent.
 					if (udptest(s) == -1) {
Checking patch gnu/packages/patches/netcat-openbsd-0007-udp-scan-timeout.patch...
Applied patch gnu/packages/patches/netcat-openbsd-0007-udp-scan-timeout.patch cleanly.
warning: squelched 1 whitespace error
warning: 6 lines add whitespace errors.

skipping https://yhetil.org/guix-devel/20160622110046.GA12755@shadowwalker/ for 61cd079
index at:
100644 61cd07994befa12e16f8dcbf08db8172c9b018cf	gnu/packages/patches/netcat-openbsd-0007-udp-scan-timeout.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).