]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Bugfix for check_address_conflicts call
authorMarios Paouris <mspaourh@gmail.com>
Fri, 18 Oct 2024 20:23:06 +0000 (23:23 +0300)
committerMarios Paouris <mspaourh@gmail.com>
Tue, 5 Nov 2024 07:16:51 +0000 (09:16 +0200)
If check_address_conflict fails then the adapter would remain open.
Also, don't unnecessarily call this function.

Signed-off-by: Marios Paouris <mspaourh@gmail.com>
tun-win32.c

index 59dd1e6b5f973590b8be1d3307413b3ed17a86c9..80d29b93a3c282c164fafe43613d1568ca7aca05 100644 (file)
@@ -78,6 +78,8 @@ typedef intptr_t (tap_callback)(struct openconnect_info *vpninfo, int type, char
 #define MAX_FALLBACK_TRIES 15
 #endif
 
+static void shutdown_tun(struct openconnect_info *vpninfo);
+
 /* a linked list of adapter information */
 struct oc_adapter_info {
        int type;
@@ -851,8 +853,10 @@ intptr_t os_setup_tun(struct openconnect_info *vpninfo)
                ret = OPEN_TUN_HARDFAIL;
        }
 
-       if (check_address_conflicts(vpninfo) < 0)
+       if (ret != OPEN_TUN_HARDFAIL && ( check_address_conflicts(vpninfo) < 0 )) {
+               shutdown_tun(vpninfo);
                ret = OPEN_TUN_HARDFAIL; /* already complained about it */
+       }
 
 safe_return:
        if (list)
@@ -950,7 +954,11 @@ int os_write_tun(struct openconnect_info *vpninfo, struct pkt *pkt)
 void os_shutdown_tun(struct openconnect_info *vpninfo)
 {
        script_config_tun(vpninfo, "disconnect");
+       shutdown_tun(vpninfo);
+}
 
+static void shutdown_tun(struct openconnect_info *vpninfo)
+{
        if (vpninfo->wintun) {
                os_shutdown_wintun(vpninfo);
                return;