Nmap Development mailing list archives

[Nmap, Ncat] Odd Nsock bug related to ENETUNREACH


From: Jacek Wielemborek <d33tah () gmail com>
Date: Thu, 05 Jun 2014 13:38:39 +0200

List,

While working on my prototype, I noticed that when you try to 
make a connection that results in ENETUNREACH (tested by issuing 
ncat 127.0.0.0 -w 1), Nsock blocks forever even if a timeout was 
specified. This is probably because it performs a non-blocking 
connect() and ignores any error codes other than EINPROGRESS or 
EAGAIN, yet it schedules an event. Then, the main loop calls 
engine's file descriptor watching function (epoll, select etc) on 
an empty FD set, effectively waiting forever.

This affects NSE scripts as well. Create test.nse file with the 
folowing code and run nmap --script test.nse -d 127.0.0.0 -sn:

local stdnse = require "stdnse"
local nmap = require "nmap"

hostrule = function()
  return true
end

action = function(host)
        stdnse.print_debug("test.nse started!")
        local sock = nmap.new_socket()
        local constatus, conerr = sock:connect("127.0.0.0", 80)
end

--END OF FILE

I believe that Nsock should run the connect handler immediately 
when it detects the error, behaving in a way similar to other 
error messages.

The box I tested it on is Fedora 20, kernel  
3.14.2-200.fc20.x86_64. I can provide any further details if 
needed.

Yours,
Jacek Wielemborek

Attachment: signature.asc
Description: This is a digitally signed message part.

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

Current thread: