c0756e8f2c
- Drop all patches that were never upstreamed: * connect-timeout.patch * dccp.patch * gcc-warnings.patch * getservbyname.patch * glib-strlcpy.patch * help-version-exit.patch * nc-1.84-udp_stop.patch * netcat-info.patch * netcat-openbsd-debian.patch * netcat-openbsd-examples.patch * netcat-openbsd-openbsd-compat.patch * no-strtonum.patch * pollhup.patch * quit-timer.patch * reuseaddr.patch * send-crlf.patch * silence-z.patch * socks-b64-prototype.patch * udp-scan-timeout.patch * verbose-message-to-stderr.patch * verbose-numeric-port.patch - Switch to debian package to not waste resources on doing exactly the same. - Switches URL for debian package - Apply patches already prepared for debian package * port-to-linux-with-libsd.patch * compile-without-TLS-support.patch * connect-timeout.patch * get-sev-by-name.patch OBS-URL: https://build.opensuse.org/request/show/510980 OBS-URL: https://build.opensuse.org/package/show/network:utilities/netcat-openbsd?expand=0&rev=16
57 lines
1.2 KiB
Diff
57 lines
1.2 KiB
Diff
From: Aron Xu <aron@debian.org>
|
|
Date: Mon, 13 Feb 2012 15:29:37 +0800
|
|
Subject: udp scan timeout
|
|
|
|
---
|
|
netcat.c | 23 +++++++++++++++--------
|
|
1 file changed, 15 insertions(+), 8 deletions(-)
|
|
|
|
--- a/netcat.c
|
|
+++ b/netcat.c
|
|
@@ -129,6 +129,8 @@
|
|
#define CONNECTION_FAILED 1
|
|
#define CONNECTION_TIMEOUT 2
|
|
|
|
+#define UDP_SCAN_TIMEOUT 3 /* Seconds */
|
|
+
|
|
/* Command Line Options */
|
|
int dflag; /* detached, no stdin */
|
|
int Fflag; /* fdpass sock to stdout */
|
|
@@ -774,7 +776,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) {
|
|
@@ -1693,15 +1695,20 @@ build_ports(char *p)
|
|
int
|
|
udptest(int s)
|
|
{
|
|
- int i, ret;
|
|
+ int i, t;
|
|
|
|
- for (i = 0; i <= 3; i++) {
|
|
- if (write(s, "X", 1) == 1)
|
|
- ret = 1;
|
|
- else
|
|
- ret = -1;
|
|
+ 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
|