]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Exit if a proper message instead of segfault on Android without management
authorArne Schwabe <arne@rfc2549.org>
Mon, 20 Feb 2023 13:14:24 +0000 (14:14 +0100)
committerGert Doering <gert@greenie.muc.de>
Mon, 20 Feb 2023 16:03:38 +0000 (17:03 +0100)
The Android implementation is relying on the management interface to be
always available. Trying to run the Android binary without the mangament
interface outside the app leads to a segfault. Exit with a FATAL error
instead.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230220131424.1749736-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26288.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/manage.c
src/openvpn/socket.c

index 8397d3cf67f0df33c99160ba59a472d01b75b95e..a55e5d78823b5976ad70bc64e0f864b35e507743 100644 (file)
@@ -2192,6 +2192,10 @@ man_recv_with_fd(int fd, void *ptr, size_t nbytes, int flags, int *recvfd)
 bool
 management_android_control(struct management *man, const char *command, const char *msg)
 {
+    if (!man)
+    {
+        msg(M_FATAL, "Required management interface not available.");
+    }
     struct user_pass up;
     CLEAR(up);
     strncpy(up.username, msg, sizeof(up.username)-1);
index 42d953390461ef4a1656f70d3d6e44d2a82066ab..eff21ca5663a9f142ff29fb494034975cf4a9539 100644 (file)
@@ -1161,6 +1161,11 @@ create_socket(struct link_socket *sock, struct addrinfo *addr)
 static void
 protect_fd_nonlocal(int fd, const struct sockaddr *addr)
 {
+    if (!management)
+    {
+        msg(M_FATAL, "Required management interface not available.")
+    }
+
     /* pass socket FD to management interface to pass on to VPNService API
      * as "protected socket" (exempt from being routed into tunnel)
      */