From 6e02a3e9a9183cdfd15452c4a0d0ee2c60f561af Mon Sep 17 00:00:00 2001 From: emanuele-f Date: Wed, 30 Jun 2021 16:16:28 +0200 Subject: [PATCH] Fix crash when no interface is available --- app/src/main/jni/pcapd/pcapd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/jni/pcapd/pcapd.c b/app/src/main/jni/pcapd/pcapd.c index 6039a042..a82851e6 100644 --- a/app/src/main/jni/pcapd/pcapd.c +++ b/app/src/main/jni/pcapd/pcapd.c @@ -583,6 +583,8 @@ static int run_pcap_dump(int uid_filter) { if(init_pcapd_capture(&rt) < 0) goto cleanup; + rt.pf = -1; + rt.ifidx = -1; check_capture_interface(&rt); rv = 0; @@ -676,7 +678,7 @@ static int run_pcap_dump(int uid_filter) { if((rt.pd == NULL) && (now >= next_interface_recheck)) { check_capture_interface(&rt); next_interface_recheck = now + 5; - } else if((now >= next_stats_update)) { + } else if((rt.pd != NULL) && (now >= next_stats_update)) { pcap_stats(rt.pd, &stats); next_stats_update = now + 3; }