aboutsummaryrefslogtreecommitdiff
path: root/savefile.c
diff options
context:
space:
mode:
authorGuy Harris <gharris@sonic.net>2021-11-02 22:37:13 -0700
committerGuy Harris <gharris@sonic.net>2021-11-02 22:37:13 -0700
commit56c60dd660297b5cf02afcb9fdc4f92689de0353 (patch)
treec07888981ad18ad9eb96e9896a26ce8998aa9658 /savefile.c
parent292ce0079b21df0dc34233e1b094a556d6b84753 (diff)
Use PACKET_COUNT_IS_UNLIMITED() in pcap_offline_read().
That's what should always be used to check whether a packet count argument means "give me all the packets you have". Check it first, so we don't compare the packet count against a zero or negative value.
Diffstat (limited to 'savefile.c')
-rw-r--r--savefile.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/savefile.c b/savefile.c
index 9e6a7deb..acd915cf 100644
--- a/savefile.c
+++ b/savefile.c
@@ -663,7 +663,8 @@ pcap_offline_read(pcap_t *p, int cnt, pcap_handler callback, u_char *user)
if ((fcode = p->fcode.bf_insns) == NULL ||
pcap_filter(fcode, data, h.len, h.caplen)) {
(*callback)(user, &h, data);
- if (++n >= cnt && cnt > 0)
+ n++; /* count the packet */
+ if (!PACKET_COUNT_IS_UNLIMITED(cnt) && n >= cnt)
break;
}
}