From f8f73ddb46e7b812547e570ecf4ddcc5dc76131a Mon Sep 17 00:00:00 2001 From: Michal Hlavinka Date: Wed, 19 Sep 2012 15:05:39 +0200 Subject: [PATCH] shutdown socket on EOF (#845075) --- nmap-6.01-r29743.patch | 27 +++++++++++++++++++++++++++ nmap.spec | 9 ++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 nmap-6.01-r29743.patch diff --git a/nmap-6.01-r29743.patch b/nmap-6.01-r29743.patch new file mode 100644 index 0000000..58c44c0 --- /dev/null +++ b/nmap-6.01-r29743.patch @@ -0,0 +1,27 @@ +diff -up nmap-6.01/ncat/ncat_connect.c.r29743 nmap-6.01/ncat/ncat_connect.c +--- nmap-6.01/ncat/ncat_connect.c.r29743 2012-09-19 14:56:37.889102887 +0200 ++++ nmap-6.01/ncat/ncat_connect.c 2012-09-19 14:56:56.148241822 +0200 +@@ -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; +@@ -732,6 +740,8 @@ static void read_stdin_handler(nsock_poo + 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) { diff --git a/nmap.spec b/nmap.spec index ccc67eb..7d87f69 100644 --- a/nmap.spec +++ b/nmap.spec @@ -4,7 +4,7 @@ Name: nmap Epoch: 2 Version: 6.01 #global prerelease TEST5 -Release: 5%{?dist} +Release: 6%{?dist} # nmap is GPLv2 # zenmap is GPLv2 and LGPLv2+ (zenmap/higwidgets) and GPLv2+ (zenmap/radialnet) # libdnet-stripped is BSD (advertising clause rescinded by the Univ. of California in 1999) with some parts as Public Domain (crc32) @@ -35,6 +35,9 @@ Patch4: zenmap-621887-workaround.patch # upstream provided patch for rhbz#845005, not yet in upstream repository Patch5: ncat_reg_stdin.diff +# shutdown socket on EOF, sent upstream +Patch6: nmap-6.01-r29743.patch + URL: http://nmap.org/ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: openssl-devel, gtk2-devel, lua-devel, libpcap-devel, pcre-devel @@ -85,6 +88,7 @@ uses. %patch2 -p1 -b .noms %patch4 -p1 -b .bz637403 %patch5 -p1 -b .ncat_reg_stdin +%patch6 -p1 -b .r29743 #be sure we're not using tarballed copies of some libraries rm -rf liblua libpcap libpcre macosx mswin32 @@ -212,6 +216,9 @@ rm -rf $RPM_BUILD_ROOT %{_mandir}/man1/xnmap.1.gz %changelog +* Wed Sep 19 2012 Michal Hlavinka - 2:6.01-6 +- shutdown socket on EOF (#845075) + * Mon Aug 13 2012 Michal Hlavinka - 2:6.01-5 - ncat did not work when file was used as input (#845005)