Nmap Development mailing list archives

Re: [PATCH] Ncat as a client should quit event loop on EOF only if recvonly


From: Tomas Hozza <thozza () redhat com>
Date: Fri, 8 Feb 2013 06:30:44 -0500 (EST)

----- Original Message -----
On Thu, Feb 07, 2013 at 03:52:32AM -0500, Tomas Hozza wrote:
Ncat acting as a client should call nsock_loop_quit()
on reading EOF from socket only if o.recvonly is set.
If not, Ncat should call shutdown(<sock_fd>, SHUT_RD).

The current code can result in situation when client
receives EOF from the server and quits the event loop.
This would prevent client from sending any more data
to the server.

This can be reproduced using TCP:

1. run server: # ncat -l 6666
2. run client: # ncat -4 localhost 6666
3. send EOF from server to client
4. client will exit the event loop and terminate the connection

- client should NOT quit the event loop if --recv-only
is not used.

I'm attaching proposed patch.

Looks good, thanks. Can you add a test along the lines of the one
added
by Michal Hlavinka for a similar EOF issue?

http://seclists.org/nmap-dev/2012/q4/337
http://seclists.org/nmap-dev/2012/q4/att-337/ncat-shutdown2.patch

David Fifield

I just noticed, that the server behaviour is the same as for client.
If server reads EOF from the socket it quits even if o.recvonly is
not set. Do you think that the server should be fixed, too? So that
it quits on reading EOF from socket only if o.recvonly is set.

I can prepare a patch and test if you think the server behaviour
should be fixed.

Regards,

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


Current thread: