7d95763414
Split up the ubuntu patch OBS-URL: https://build.opensuse.org/request/show/197181 OBS-URL: https://build.opensuse.org/package/show/network:utilities/netcat-openbsd?expand=0&rev=12
51 lines
1.2 KiB
Diff
51 lines
1.2 KiB
Diff
Index: netcat-openbsd-1.89/netcat.c
|
|
===================================================================
|
|
--- netcat-openbsd-1.89.orig/netcat.c 2008-01-22 16:17:30.000000000 -0500
|
|
+++ netcat-openbsd-1.89/netcat.c 2008-01-22 16:17:34.000000000 -0500
|
|
@@ -69,6 +69,8 @@
|
|
#define CONNECTION_FAILED 1
|
|
#define CONNECTION_TIMEOUT 2
|
|
|
|
+#define UDP_SCAN_TIMEOUT 3 /* Seconds */
|
|
+
|
|
/* Command Line Options */
|
|
int dflag; /* detached, no stdin */
|
|
int iflag; /* Interval Flag */
|
|
@@ -376,7 +378,7 @@
|
|
continue;
|
|
|
|
ret = 0;
|
|
- if (vflag) {
|
|
+ if (vflag && !uflag) {
|
|
/* For UDP, make sure we are connected. */
|
|
if (uflag) {
|
|
if (udptest(s) == -1) {
|
|
@@ -841,15 +843,20 @@
|
|
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
|