mirror of
https://github.com/emanuele-f/PCAPdroid.git
synced 2026-07-09 21:18:12 +08:00
Fix firewall not working with duplicate rules
The firewall was silently failing to load in case duplicate rules were supplied. This could happen, for example, with rules for subdomains.
This commit is contained in:
parent
4eb7f7f0e9
commit
2b57c40dfe
@ -325,6 +325,7 @@ void blacklist_get_stats(const blacklist_t *bl, blacklists_stats_t *stats) {
|
||||
|
||||
static int bl_load_list_of_type(blacklist_t *bl, JNIEnv *env, jobject list, blacklist_type tp) {
|
||||
int num_items = (*env)->CallIntMethod(env, list, mids.listSize);
|
||||
int num_loaded = 0;
|
||||
|
||||
for(int i=0; i<num_items; i++) {
|
||||
jstring *obj = (*env)->CallObjectMethod(env, list, mids.listGet, i);
|
||||
@ -348,14 +349,16 @@ static int bl_load_list_of_type(blacklist_t *bl, JNIEnv *env, jobject list, blac
|
||||
(*env)->ReleaseStringUTFChars(env, obj, val);
|
||||
(*env)->DeleteLocalRef(env, obj);
|
||||
|
||||
if(rv != 0) {
|
||||
if(rv == 0) {
|
||||
num_loaded++;
|
||||
} else if(rv != -EADDRINUSE) {
|
||||
log_e("bl add %s failed: %d", val, rv);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return num_items;
|
||||
return num_loaded;
|
||||
}
|
||||
|
||||
/* ******************************************************* */
|
||||
|
||||
@ -822,6 +822,7 @@ Java_com_emanuelef_remote_1capture_CaptureService_reloadBlocklist(JNIEnv *env, j
|
||||
}
|
||||
|
||||
if(blacklist_load_list_descriptor(bl, env, ld) < 0) {
|
||||
log_f("Could not load firewall rules. Check the log for more details");
|
||||
blacklist_destroy(bl);
|
||||
return false;
|
||||
}
|
||||
@ -868,6 +869,7 @@ Java_com_emanuelef_remote_1capture_CaptureService_reloadFirewallWhitelist(JNIEnv
|
||||
}
|
||||
|
||||
if(blacklist_load_list_descriptor(wl, env, whitelist) < 0) {
|
||||
log_f("Could not load firewall whitelist rules. Check the log for more details");
|
||||
blacklist_destroy(wl);
|
||||
return false;
|
||||
}
|
||||
@ -909,6 +911,7 @@ Java_com_emanuelef_remote_1capture_CaptureService_reloadMalwareWhitelist(JNIEnv
|
||||
}
|
||||
|
||||
if(blacklist_load_list_descriptor(wl, env, whitelist) < 0) {
|
||||
log_f("Could not load malware whitelist rules. Check the log for more details");
|
||||
blacklist_destroy(wl);
|
||||
return false;
|
||||
}
|
||||
@ -949,6 +952,7 @@ Java_com_emanuelef_remote_1capture_CaptureService_reloadDecryptionWhitelist(JNIE
|
||||
}
|
||||
|
||||
if(blacklist_load_list_descriptor(wl, env, whitelist) < 0) {
|
||||
log_f("Could not load decryption whitelist. Check the log for more details");
|
||||
blacklist_destroy(wl);
|
||||
return false;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user