Nmap Development mailing list archives

Re: [PATCH] ncat: port 0 is valid


From: David Fifield <david () bamsoftware com>
Date: Fri, 22 Feb 2013 23:04:05 -0800

On Wed, Feb 20, 2013 at 12:56:35AM +0100, Xose Vazquez Perez wrote:
hi,

port 0 binds to an arbitrary unused port.

Index: ncat/ncat_main.c
===================================================================
--- ncat/ncat_main.c  (revision 30610)
+++ ncat/ncat_main.c  (working copy)
@@ -700,7 +700,7 @@
 
         errno = 0;
         long_port = strtol(argv[optind], NULL, 10);
-        if (errno != 0 || long_port <= 0 || long_port > 65535)
+        if (errno != 0 || long_port < 0 || long_port > 65535)
             bye("Invalid port number \"%s\".", argv[optind]);
 
         o.portno = (unsigned short) long_port;

Thanks, this is a good idea. It can possibly allow us to parallelize our
tests.

Can you check that having a 0 in srcaddr_u doesn't have any bad effects
elsewhere? In particular, the message
        Ncat: Listening on 127.0.0.1:0
Should instead show the actual port number being used, found with
getsockname.

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


Current thread: