nmap/nmap-6.01-shutdown.patch
2012-11-29 11:23:42 +01:00

44 lines
1.6 KiB
Diff

diff -up nmap-6.01/ncat/ncat_core.c.shutdown nmap-6.01/ncat/ncat_core.c
diff -up nmap-6.01/ncat/ncat_core.h.shutdown nmap-6.01/ncat/ncat_core.h
diff -up nmap-6.01/ncat/ncat_listen.c.shutdown nmap-6.01/ncat/ncat_listen.c
--- nmap-6.01/ncat/ncat_listen.c.shutdown 2012-03-01 07:53:35.000000000 +0100
+++ nmap-6.01/ncat/ncat_listen.c 2012-11-22 18:14:05.991381724 +0100
@@ -317,10 +317,13 @@ static int ncat_listen_stream(int proto)
}else {
/* Read from stdin and write to all clients. */
rc = read_stdin();
- if (rc == 0 && o.sendonly)
- /* There will be nothing more to send. If we're not
- receiving anything, we can quit here. */
- return 0;
+ if (rc == 0) {
+ if (o.sendonly)
+ /* There will be nothing more to send. If we're not
+ receiving anything, we can quit here. */
+ return 0;
+ shutdown_sockets(SHUT_WR);
+ }
if (rc < 0)
return 1;
}
@@ -495,6 +498,19 @@ int read_stdin(void)
return nbytes;
}
+void shutdown_sockets(int how)
+{
+ struct fdinfo *fdn;
+ int i;
+ for (i = 0; i <= broadcast_fdlist.fdmax; i++) {
+ if (!FD_ISSET(i, &master_broadcastfds))
+ continue;
+
+ fdn = get_fdinfo(&broadcast_fdlist, i);
+ shutdown(fdn->fd, how);
+ }
+}
+
/* Read from a client socket and write to stdout. Return the number of bytes
read from the socket, or -1 on error. */
int read_socket(int recv_fd)