aboutsummaryrefslogtreecommitdiff
path: root/example/ndpiReader.c
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2024-11-04 22:14:09 +0100
committerLuca Deri <deri@ntop.org>2024-11-04 22:14:09 +0100
commit35ef56cc2467e907fa1827a4e8058893dea0b8a7 (patch)
treec760588945ac18b036decf3ba11c2b8372d94bab /example/ndpiReader.c
parent183175fc6b4c9e610fb22dfd69946cc7063b6a63 (diff)
Crash fix when -f is specified with a non-existing pcap file (-i)
Diffstat (limited to 'example/ndpiReader.c')
-rw-r--r--example/ndpiReader.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 8ea13b6ab..e34c973ab 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -4465,9 +4465,10 @@ 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));
@@ -4475,6 +4476,7 @@ static void configurePcapHandle(pcap_t * pcap_handle) {
}
bpf_cfilter = &bpf_code;
}
+
if(pcap_setfilter(pcap_handle, bpf_cfilter) < 0) {
printf("pcap_setfilter error: '%s'\n", pcap_geterr(pcap_handle));
} else {