Skip to content

Commit

Permalink
Crash fix when -f is specified with a non-existing pcap file (-i)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaderi committed Nov 4, 2024
1 parent 183175f commit 35ef56c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions example/ndpiReader.c
Original file line number Diff line number Diff line change
Expand Up @@ -4465,16 +4465,18 @@ static int getNextPcapFileFromPlaylist(u_int16_t thread_id, char filename[], u_i
* @brief Configure the pcap handle
*/
static void configurePcapHandle(pcap_t * pcap_handle) {

if(!pcap_handle)
return;

if(bpfFilter != NULL) {

if(!bpf_cfilter) {
if(pcap_compile(pcap_handle, &bpf_code, bpfFilter, 1, 0xFFFFFF00) < 0) {
printf("pcap_compile error: '%s'\n", pcap_geterr(pcap_handle));
return;
}
bpf_cfilter = &bpf_code;
}

if(pcap_setfilter(pcap_handle, bpf_cfilter) < 0) {
printf("pcap_setfilter error: '%s'\n", pcap_geterr(pcap_handle));
} else {
Expand Down

0 comments on commit 35ef56c

Please sign in to comment.