From 65af87f0d9d7f69ed5a519e983ab3d6f67e1b4ea Mon Sep 17 00:00:00 2001 From: elluisian Date: Fri, 30 Aug 2024 22:10:18 +0200 Subject: [PATCH] droidvnc-ng.c: Changed default action in case of errors Contrary to before, now, if some error occurs during address translation, it is reported, instead of using the 0.0.0.0 address. --- app/src/main/cpp/droidvnc-ng.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/cpp/droidvnc-ng.c b/app/src/main/cpp/droidvnc-ng.c index 9fbc22fa..e9c927aa 100644 --- a/app/src/main/cpp/droidvnc-ng.c +++ b/app/src/main/cpp/droidvnc-ng.c @@ -317,13 +317,18 @@ JNIEXPORT jboolean JNICALL Java_net_christianbeier_droidvnc_1ng_MainService_vncS in_addr_t address = 0; // Default is 0.0.0.0 if (listenIf != NULL) { - const char *listenIfNative = (*env)->GetStringUTFChars(env, listenIf, NULL); - if (!rfbStringToAddr((char*)listenIfNative, &address)) { - address = 0; // If problems arise, assume 0.0.0.0 + const char *cListenInterface = (*env)->GetStringUTFChars(env, listenIf, NULL); + int addrConvSucceded = rfbStringToAddr((char*)cListenInterface, &address); + (*env)->ReleaseStringUTFChars(env, listenIf, cListenInterface); + + if (!addrConvSucceded) { + __android_log_print(ANDROID_LOG_ERROR, TAG, "vncStartServer: invalid listen address"); + Java_net_christianbeier_droidvnc_1ng_MainService_vncStopServer(env, thiz); + return JNI_FALSE; } - (*env)->ReleaseStringUTFChars(env, listenIf, listenIfNative); } + // With the listenInterface property one can define where the server will be available theScreen->listenInterface = address; theScreen->port = port;