Nmap Development mailing list archives

Re: [Nmap, Ncat] Odd Nsock bug related to ENETUNREACH


From: Henri Doreau <henri.doreau () gmail com>
Date: Mon, 28 Jul 2014 21:56:14 +0200

2014-07-28 20:29 GMT+02:00 Henri Doreau <henri.doreau () gmail com>:
2014-07-28 20:23 GMT+02:00 Jacek Wielemborek <d33tah () gmail com>:
28.07.2014 20:19, Henri Doreau:
2014-07-28 15:42 GMT+02:00 Jacek Wielemborek <d33tah () gmail com>:
Just wanted to point out that nsock/include/nsock.h says:

/* EVENT CREATION FUNCTIONS
 * ---
 * These functions request asynchronous
 * notification of completion of an event.  The handler will never be
 * synchronously called back during the event creation call (that causes too
 * many hard to debug errors and plus we don't want people to have to deal with
 * callbacks until they actually call nsock_loop). */

IIRC my IRC chat with Henri, this is not true anymore as ENETUNREACH
errors can cause callbacks to run synchronously.

Hello,

thanks, you're right, this comment isn't accurate anymore (actually it
wasn't totally before anyway). Before I nuke it, do we agree that
calling handlers from outside nsock_loop to report errors is
acceptable? Jacek, you've become a heavy nsock user. What do you
think?

Regards


I think that at the very least all ncat_connect_* calls should be
checked very carefully as they could have been written with the
assumption that the callbacks will be written when we call nsock_loop.

Anyway, I think that it's very unintuitive and should be changed, but if
all the Nmap family programs are bug-free in this region, IMHO this is
acceptable (provided that we shout in the comments of ncat.h as well as
the relevant .c files about this behavior).


Ok, then let me write a test patch to make nsock report errors only
from within nsock_loop (except for IOD/NSP deletion, where I don't
think it would make sense) so that we can see what we find best.

Regards

--
Henri

There you go! It's a quickly written and almost untested PoC, but you
have the idea (and it seems to work as expected).

Regards

-- 
Henri

Attachment: nsock_deferred_errors.patch
Description:

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

Current thread: