Skip to content

Commit

Permalink
fuzz: check libpcap timestamp consistency
Browse files Browse the repository at this point in the history
That is microseconds should be positive
  • Loading branch information
catenacyber authored and victorjulien committed Jan 17, 2023
1 parent d339b89 commit 39b626c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tests/fuzz/fuzz_sigpcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
//loop over packets
r = pcap_next_ex(pkts, &header, &pkt);
p = PacketGetFromAlloc();
if (r <= 0 || header->ts.tv_sec >= INT_MAX - 3600) {
if (r <= 0 || header->ts.tv_sec >= INT_MAX - 3600 || header->ts.tv_usec < 0) {
goto bail;
}
p->ts.tv_sec = header->ts.tv_sec;
Expand All @@ -187,7 +187,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
}
}
r = pcap_next_ex(pkts, &header, &pkt);
if (r <= 0 || header->ts.tv_sec >= INT_MAX - 3600) {
if (r <= 0 || header->ts.tv_sec >= INT_MAX - 3600 || header->ts.tv_usec < 0) {
goto bail;
}
PacketRecycle(p);
Expand Down

0 comments on commit 39b626c

Please sign in to comment.