diff options
author | Guy Harris <gharris@sonic.net> | 2021-11-02 22:37:13 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2021-11-02 22:37:13 -0700 |
commit | 56c60dd660297b5cf02afcb9fdc4f92689de0353 (patch) | |
tree | c07888981ad18ad9eb96e9896a26ce8998aa9658 /savefile.c | |
parent | 292ce0079b21df0dc34233e1b094a556d6b84753 (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.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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; } } |