Skip to content

Commit

Permalink
test/pcapng: fix 32-bit overflow
Browse files Browse the repository at this point in the history
The conversion from seconds to nanoseconds in the pcapng test
would overflow on 32 bit platforms leading to this test failing.

Reported-by: Luca Boccassi <bluca@debian.org>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Tested-by: Luca Boccassi <bluca@debian.org>
  • Loading branch information
shemminger authored and tmonjalo committed Jul 29, 2024
1 parent 7b1fef7 commit a798194
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/test/test_pcapng.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ parse_pcap_packet(u_char *user, const struct pcap_pkthdr *h,
* but the file is open in nanonsecond mode therefore
* the timestamp is really in timespec (ie. nanoseconds).
*/
ns = h->ts.tv_sec * NS_PER_S + h->ts.tv_usec;
ns = (uint64_t)h->ts.tv_sec * NS_PER_S + h->ts.tv_usec;
if (ns < ctx->start_ns || ns > ctx->end_ns) {
char tstart[128], tend[128];

Expand Down

0 comments on commit a798194

Please sign in to comment.