Fix crash when no interface is available

This commit is contained in:
emanuele-f 2021-06-30 16:16:28 +02:00
parent 7d52548d1d
commit 6e02a3e9a9

View File

@ -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;
}