Re: Ncat -w -i options bugfixing

Carlos Manso <[email protected]>
Newsgroups gmane.comp.security.nmap.devel
Message-ID <CAA6Uyqod-FR5NT=J4MCYu0BSeZTzJs5KbbafUfzkGv=TZ-iisw@mail.gmail.com>
Hello again,

I've taken the liberty of making a simple patch for the behaviour I
commented on my last mail, -i option causing ncat in listen mode to quit
with no connections, I hope it is ok.

Regards,

Carlos Manso.

_______________________________________________
Sent through the dev mailing list
https://nmap.org/mailman/listinfo/dev
Archived at http://seclists.org/nmap-dev/
ncat_i_option.diff (text/plain, 1.2 KB)
diff --git a/ncat/ncat_listen.c b/ncat/ncat_listen.c
index e41369d..3ce60dc 100644
--- a/ncat/ncat_listen.c
+++ b/ncat/ncat_listen.c
@@ -344,7 +344,10 @@ static int ncat_listen_stream(int proto)
         if (o.idletimeout > 0)
             ms_to_timeval(tvp, o.idletimeout);
 
-        fds_ready = fselect(client_fdlist.fdmax + 1, &readfds, &writefds, NULL, tvp);
+        if (get_conn_count())
+            fds_ready = fselect(client_fdlist.fdmax + 1, &readfds, &writefds, NULL, tvp);
+        else
+            fds_ready = fselect(client_fdlist.fdmax + 1, &readfds, &writefds, NULL, NULL);
 
         if (o.debug > 1)
             logdebug("select returned %d fds ready\n", fds_ready);
@@ -806,7 +809,10 @@ static int ncat_listen_dgram(int proto)
             if (o.idletimeout > 0)
                 ms_to_timeval(tvp, o.idletimeout);
 
-            fds_ready = fselect(listen_fdlist.fdmax + 1, &fds, NULL, NULL, tvp);
+            if (get_conn_count())
+                fds_ready = fselect(listen_fdlist.fdmax + 1, &fds, NULL, NULL, tvp);
+            else
+                fds_ready = fselect(listen_fdlist.fdmax + 1, &fds, NULL, NULL, NULL);
 
             if (o.debug > 1)
                 logdebug("select returned %d fds ready\n", fds_ready);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.