Nmap Development mailing list archives

Re: Nsock new engines


From: Henri Doreau <henri.doreau () gmail com>
Date: Fri, 26 Oct 2012 11:42:18 +0200

2012/10/26 David Fifield <david () bamsoftware com>:
On Thu, Oct 25, 2012 at 03:48:27PM -0500, Kris Katterjohn wrote:
On 10/25/2012 02:02 PM, Henri Doreau wrote:
it looks like WSAPoll isn't able to deal with stdin, even though I can't
find anything in the WSAPoll() documentation that would explain this
difference of behavior with select().

Does anyone know a way to do it? I unfortunately don't, and couldn't find
anything that would work for both stdin options (tty, pipes, files) and
sockets. Since only ncat should be affected there, maybe the patch
attached (untested) would be an acceptable fix? It enforces the use of
the select engine on windows when stdin is a tty. Could you please give
it a try? (also with piping something, like echo, to ncat, and
redirecting a regular file to ncat' stdin).


It sounds like you're suggesting that select() works for stdin on Windows
but WSAPoll() doesn't.  Is that right?  Although it's gone through some
changes over the years, I originally wrote the fselect()[1] in nbase because
select() doesn't work with stdin on Windows (and I did it for ncat and
nsock).  A simple grep shows that fselect() is called in engine_select.c for
nsock instead of the vanilla select().

If I'm not misunderstanding what you're saying, then I think WSAPoll() and
select() are not that different in their behavior wrt stdin (although I have
no experience with WSAPoll afaik).  I don't have a direct suggestion for a
fix, but I think it's important to note that there's a workaround for
select() and it's not doing "the right thing" with stdin on Windows either.

I think your analysis is correct, Kris. We probably need a similar
workaround for poll as for select (fpoll?). Henri, let's unconditionally
use the select engine for Ncat on Windows for now until we have a fix.

David Fifield

Thanks Kris, this makes completely sense. I'll try to implement a
fpoll() at some point, looks like it's the way to go.

For now I've enforced the use of the select engine for ncat on windows
(see r30118).

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


Current thread: