1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Let all nsock engines use STDIN on Windows!

This commit is contained in:
dmiller
2024-11-06 16:48:29 +00:00
parent 1c3fc17d2f
commit 1e8c1ab3cd
2 changed files with 12 additions and 1 deletions

View File

@@ -262,6 +262,7 @@ struct niod {
#define IOD_REGISTERED 0x01
#define IOD_PROCESSED 0x02 /* internally used by engine_kqueue.c */
#define IOD_STDIN 0x04
#define IOD_PROPSET(iod, flag) ((iod)->_flags |= (flag))
#define IOD_PROPCLR(iod, flag) ((iod)->_flags &= ~(flag))

View File

@@ -63,6 +63,10 @@
#include "nsock_pcap.h"
#endif
#ifdef WIN32
#include <nbase_winunix.h>
#endif
#include <string.h>
@@ -97,7 +101,13 @@ nsock_iod nsock_iod_new2(nsock_pool nsockp, int sd, void *userdata) {
nsi->sd = -1;
nsi->state = NSIOD_STATE_INITIAL;
} else if (sd == STDIN_FILENO) {
#ifdef WIN32
nsi->sd = win_stdin_start_thread();
assert(nsi->sd != INVALID_SOCKET);
#else
nsi->sd = STDIN_FILENO;
#endif
IOD_PROPSET(nsi, IOD_STDIN);
nsi->state = NSIOD_STATE_UNKNOWN;
} else {
nsi->sd = dup_socket(sd);
@@ -261,7 +271,7 @@ void nsock_iod_delete(nsock_iod nsockiod, enum nsock_del_mode pending_response)
}
#endif
if (nsi->sd >= 0 && nsi->sd != STDIN_FILENO) {
if (nsi->sd >= 0 && !IOD_PROPGET(nsi, IOD_STDIN)) {
close(nsi->sd);
nsi->sd = -1;
}