mirror of
https://github.com/nmap/nmap.git
synced 2025-12-26 01:19:03 +00:00
Use a mutex for ike.lua's bind to udp/500.
Based on a patch by Jesper Kückelhahn. http://seclists.org/nmap-dev/2013/q2/347
This commit is contained in:
@@ -355,6 +355,10 @@ function send_request( host, port, packet )
|
||||
local socket = nmap.new_socket()
|
||||
local s_status, r_status, data, i, hexstring, _
|
||||
|
||||
-- lock resource (port 500/udp)
|
||||
local mutex = nmap.mutex("ike_port_500");
|
||||
mutex "lock";
|
||||
|
||||
-- send the request packet
|
||||
socket:set_timeout(1000)
|
||||
socket:bind(nil, port.number)
|
||||
@@ -368,6 +372,9 @@ function send_request( host, port, packet )
|
||||
if r_status then
|
||||
i, hexstring = bin.unpack("H" .. data:len(), data)
|
||||
socket:close()
|
||||
|
||||
-- release mutex
|
||||
mutex "done";
|
||||
return response(hexstring)
|
||||
else
|
||||
socket:close()
|
||||
@@ -376,6 +383,9 @@ function send_request( host, port, packet )
|
||||
socket:close()
|
||||
end
|
||||
|
||||
-- release mutex
|
||||
mutex "done";
|
||||
|
||||
return {}
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user