Skip to content

Commit d23efba

Browse files
committed
fix(core): nil-check resolveProcess callback and tun_interface
Backport chen08209#1996 (TuTouPower). Two-layer defence against the ':remote' core process SIGABRT that hits ~2s after VPN start on Android 14+ when the ':remote' subprocess is killed and respawned: Go side does not invoke a nil callback, C++ side does not call JNI methods on a null jobject.
1 parent 4f05817 commit d23efba

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

android/core/src/main/cpp/core.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ call_tun_interface_resolve_process_impl(void *tun_interface, const int protocol,
105105
const char *source,
106106
const char *target,
107107
const int uid) {
108+
if (tun_interface == nullptr) {
109+
return strdup("");
110+
}
108111
ATTACH_JNI();
109112
const auto packageName = reinterpret_cast<jstring>(env->CallObjectMethod(
110113
static_cast<jobject>(tun_interface),

core/lib.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func (th *TunHandler) handleResolveProcess(source, target net.Addr) string {
8484
_ = th.limit.Acquire(context.Background(), 1)
8585
defer th.limit.Release(1)
8686

87-
if th.listener == nil {
87+
if th.listener == nil || th.callback == nil {
8888
return ""
8989
}
9090
var protocol int

0 commit comments

Comments
 (0)