mirror of
https://github.com/zeek/zeek.git
synced 2025-10-13 12:08:20 +00:00
Fix PktSrc setting next_timestamp even when no packet available
When pcap_next failed to return packet data, such as when a live packet capture interface has no traffic, the next_timestamp member would still be set to possibly uninitialized or meaningless data. Maybe addresses #611.
This commit is contained in:
parent
928baf4b66
commit
73dcdbcfc5
1 changed files with 4 additions and 1 deletions
|
@ -21,6 +21,7 @@ PktSrc::PktSrc()
|
||||||
{
|
{
|
||||||
interface = readfile = 0;
|
interface = readfile = 0;
|
||||||
data = last_data = 0;
|
data = last_data = 0;
|
||||||
|
memset(&hdr, 0, sizeof(hdr));
|
||||||
hdr_size = 0;
|
hdr_size = 0;
|
||||||
datalink = 0;
|
datalink = 0;
|
||||||
netmask = 0xffffff00;
|
netmask = 0xffffff00;
|
||||||
|
@ -75,7 +76,9 @@ int PktSrc::ExtractNextPacket()
|
||||||
}
|
}
|
||||||
|
|
||||||
data = last_data = pcap_next(pd, &hdr);
|
data = last_data = pcap_next(pd, &hdr);
|
||||||
next_timestamp = hdr.ts.tv_sec + double(hdr.ts.tv_usec) / 1e6;
|
|
||||||
|
if ( data )
|
||||||
|
next_timestamp = hdr.ts.tv_sec + double(hdr.ts.tv_usec) / 1e6;
|
||||||
|
|
||||||
if ( pseudo_realtime )
|
if ( pseudo_realtime )
|
||||||
current_wallclock = current_time(true);
|
current_wallclock = current_time(true);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue