From 4e62532919fc18d29a56520ec271bd9b5d5fcf32 Mon Sep 17 00:00:00 2001 From: Banny Date: Sat, 6 Jan 2018 15:21:26 +0800 Subject: [PATCH] Bug fix for sdk initializer. --- app/src/main/jni/netguard/netguard.c | 3 ++- app/src/main/jni/netguard/netguard.h | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/jni/netguard/netguard.c b/app/src/main/jni/netguard/netguard.c index 087c0596..1a14ce99 100644 --- a/app/src/main/jni/netguard/netguard.c +++ b/app/src/main/jni/netguard/netguard.c @@ -98,6 +98,7 @@ JNIEXPORT jlong JNICALL Java_eu_faircode_netguard_ServiceSinkhole_jni_1init( JNIEnv *env, jobject instance, jint sdk) { struct context *ctx = calloc(1, sizeof(struct context)); + ctx->sdk = sdk; loglevel = ANDROID_LOG_WARN; @@ -408,7 +409,7 @@ void report_error(const struct arguments *args, jint error, const char *fmt, ... static jmethodID midProtect = NULL; int protect_socket(const struct arguments *args, int socket) { - if (args->sdk >= 21) + if (args->ctx->sdk >= 21) return 0; jclass cls = (*args->env)->GetObjectClass(args->env, args->instance); diff --git a/app/src/main/jni/netguard/netguard.h b/app/src/main/jni/netguard/netguard.h index 8d00c010..c314f83d 100644 --- a/app/src/main/jni/netguard/netguard.h +++ b/app/src/main/jni/netguard/netguard.h @@ -73,14 +73,13 @@ struct context { pthread_mutex_t lock; int pipefds[2]; int stopping; - int tun; + int sdk; struct ng_session *ng_session; }; struct arguments { JNIEnv *env; jobject instance; - int sdk; int tun; jboolean fwd53; jint rcode;