Skip to content

Commit

Permalink
Fix all packets would be filtered if the filter was empty
Browse files Browse the repository at this point in the history
  • Loading branch information
git-hulk committed Feb 22, 2021
1 parent 4c90e7f commit e1ad318
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/sniffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,11 @@ struct sniffer *sniffer_create(struct options *opts, char *err) {
if (!pcap) goto error;
sniffer->pcap = pcap;

bpf = sniffer_compile(sniffer->pcap, sniffer->filter, err);
if (!bpf) goto error;
sniffer->bpf = bpf;
if (!sniffer->filter) {
bpf = sniffer_compile(sniffer->pcap, sniffer->filter, err);
if (!bpf) goto error;
sniffer->bpf = bpf;
}

if (opts->script) {
lua_state = lua_state_create(opts->script, err);
Expand Down

0 comments on commit e1ad318

Please sign in to comment.