Skip to content

Commit

Permalink
Fix LightPcapNg timestamp calculation (#1535)
Browse files Browse the repository at this point in the history
* Support `ticks_per_sec` being zero

* One more fix
seladb authored Aug 14, 2024

Unverified

This user has not yet uploaded their public signing key.
1 parent 8344607 commit 0122aba
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions 3rdParty/LightPcapNg/LightPcapNg/src/light_pcapng_ext.c
Original file line number Diff line number Diff line change
@@ -422,10 +422,10 @@ int light_get_next_packet(light_pcapng_t *pcapng, light_packet_header *packet_he
timestamp = timestamp << 32;
timestamp += epb->timestamp_low;
uint64_t ticks_per_sec = pcapng->file_info->timestamp_ticks_per_second[epb->interface_id];
uint64_t packet_secs = timestamp / ticks_per_sec;
uint64_t ticks = timestamp % ticks_per_sec;
if (packet_secs <= MAXIMUM_PACKET_SECONDS_VALUE)
uint64_t packet_secs = (ticks_per_sec != 0 ? timestamp / ticks_per_sec : 0);
if (packet_secs <= MAXIMUM_PACKET_SECONDS_VALUE && packet_secs != 0)
{
uint64_t ticks = timestamp % ticks_per_sec;
packet_header->timestamp.tv_sec = packet_secs;
packet_header->timestamp.tv_nsec = (1000000000ul * ticks) / ticks_per_sec;
}

0 comments on commit 0122aba

Please sign in to comment.