mirror of
https://github.com/nmap/nmap.git
synced 2026-05-13 08:46:45 +00:00
Correctly observe timeout in broadcast-ping
This commit is contained in:
parent
94d6c605bb
commit
e82d515416
1 changed files with 5 additions and 2 deletions
|
|
@ -156,7 +156,6 @@ local broadcast_if = function(if_table,icmp_responders)
|
|||
|
||||
-- raw sniffing socket (icmp echoreply style)
|
||||
local pcap = nmap.new_socket()
|
||||
pcap:set_timeout(timeout)
|
||||
|
||||
local mtu = if_table.mtu or 256 -- 256 is minimal mtu
|
||||
|
||||
|
|
@ -185,7 +184,10 @@ local broadcast_if = function(if_table,icmp_responders)
|
|||
try( dnet:ethernet_send(ethernet_icmp) )
|
||||
end
|
||||
|
||||
while true do
|
||||
local start_time = nmap.clock_ms()
|
||||
local now = start_time
|
||||
while( now - start_time < timeout ) do
|
||||
pcap:set_timeout(timeout - (now - start_time))
|
||||
local status, plen, l2, l3data, _ = pcap:pcap_receive()
|
||||
if not status then break end
|
||||
|
||||
|
|
@ -203,6 +205,7 @@ local broadcast_if = function(if_table,icmp_responders)
|
|||
else
|
||||
stdnse.debug1("Erroneous ICMP packet received; Cannot parse IP header.")
|
||||
end
|
||||
now = nmap.clock_ms()
|
||||
end
|
||||
|
||||
pcap:close()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue