Nmap Development mailing list archives

Re: RFE: ncat should call shutdown on EOF


From: Michal Hlavinka <mhlavink () redhat com>
Date: Mon, 10 Sep 2012 09:23:20 +0200

On 09/07/2012 03:43 PM, Henri Doreau wrote:
2012/8/2 Michal Hlavinka <mhlavink () redhat com>:
Hi,

we're replacing nc in fedora with ncat and testing if the behaviour is
similar enough.

One of the differences is old nc calls shutdown on EOF. When ncat is used
and gets EOF (ctrl-d) as an input, it does nothing unless --send-only is
used. Would it be possible to call shutdown(fd,SHUT_WR) when ncat gets EOF
in input?

I used following patch. It works, but I don't know if it's correct way and
correct place for this.

--- nmap-6.01/ncat/ncat_connect.c.shutdown       2012-06-19
09:49:19.000000000 +0200
+++ nmap-6.01/ncat/ncat_connect.c       2012-08-02 15:10:34.173929687 +0200
@@ -713,7 +713,7 @@ 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) {
          loguser("%s.\n", socket_strerror(nse_errorcode(evt)));

Cheers,
Michal

Sounds good to me. Any concern for supported non UNIX-like platforms?


This function exists on UNIXes and Windows, I did not check other platforms. Seems, there is one difference - windows uses different defines, so this is needed:

#ifndef SHUT_WR
#   define SHUT_WR SD_SEND
#endif

in this file or in some header file.

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


Current thread: