1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00

Correctly observe timeout in broadcast-ping

This commit is contained in:
dmiller
2024-06-13 17:45:09 +00:00
parent 94d6c605bb
commit e82d515416

View File

@@ -156,7 +156,6 @@ local broadcast_if = function(if_table,icmp_responders)
-- raw sniffing socket (icmp echoreply style) -- raw sniffing socket (icmp echoreply style)
local pcap = nmap.new_socket() local pcap = nmap.new_socket()
pcap:set_timeout(timeout)
local mtu = if_table.mtu or 256 -- 256 is minimal mtu 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) ) try( dnet:ethernet_send(ethernet_icmp) )
end 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() local status, plen, l2, l3data, _ = pcap:pcap_receive()
if not status then break end if not status then break end
@@ -203,6 +205,7 @@ local broadcast_if = function(if_table,icmp_responders)
else else
stdnse.debug1("Erroneous ICMP packet received; Cannot parse IP header.") stdnse.debug1("Erroneous ICMP packet received; Cannot parse IP header.")
end end
now = nmap.clock_ms()
end end
pcap:close() pcap:close()