diff --git a/CHANGELOG b/CHANGELOG index 1ad132139..ed4d2168e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ # Nmap Changelog ($Id$); -*-text-*- +o [Ncat] Close connection endpoint when receiving EOF on stdin. [Michal Hlavinka]. + o Fixed interface listing on NetBSD. The bug was first noticed by Fredrik Pettai and diagnosed by Jan Schaumann. [David Fifield] diff --git a/ncat/ncat_connect.c b/ncat/ncat_connect.c index f29cbc6d4..0114ae70b 100644 --- a/ncat/ncat_connect.c +++ b/ncat/ncat_connect.c @@ -113,6 +113,14 @@ #include #endif +#ifdef WIN32 +/* Define missing constant for shutdown(2). + * See: + * http://msdn.microsoft.com/en-us/library/windows/desktop/ms740481%28v=vs.85%29.aspx + */ +#define SHUT_WR SD_SEND +#endif + struct conn_state { nsock_iod sock_nsi; nsock_iod stdin_nsi; @@ -733,6 +741,8 @@ static void read_stdin_handler(nsock_pool nsp, nsock_event evt, void *data) if (o.sendonly) { /* In --send-only mode, exit after EOF on stdin. */ nsock_loop_quit(nsp); + } else { + shutdown(nsi_getsd(cs.sock_nsi), SHUT_WR); } return; } else if (status == NSE_STATUS_ERROR) {