mirror of
https://github.com/nmap/nmap.git
synced 2025-12-17 21:19:01 +00:00
Do a connect on rpc-grind UDP sockets to invoke socket_lock.
This connect should be side effect–free except for calling socket_lock, which prevents the creation of an excessive number of sockets. Not using the lock was causing "Too many open files" errors. We should have a cleaner general solution for this, and not require scripts to "connect" their unconnected UDP sockets. I seem to remember that there was a good reason for not enforcing the lock on socket creation, but only on connect, as we do. http://seclists.org/nmap-dev/2012/q4/435
This commit is contained in:
@@ -187,11 +187,15 @@ Comm = {
|
|||||||
local resvport = math.random(1, 1024)
|
local resvport = math.random(1, 1024)
|
||||||
socket = nmap.new_socket("udp")
|
socket = nmap.new_socket("udp")
|
||||||
status, err = socket:bind(nil, resvport)
|
status, err = socket:bind(nil, resvport)
|
||||||
if status then break end
|
if status then
|
||||||
socket:close()
|
status, err = socket:connect(host, port)
|
||||||
|
if status or err == "TIMEOUT" then break end
|
||||||
|
socket:close()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
socket = nmap.new_socket("udp")
|
socket = nmap.new_socket("udp")
|
||||||
|
status, err = socket:connect(host, port)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if (not(status)) then
|
if (not(status)) then
|
||||||
|
|||||||
Reference in New Issue
Block a user