Fix unintentional reconnection on disconnect request
[platform/upstream/connman.git] / gsupplicant / supplicant.c
index 8329975..723f2cf 100755 (executable)
@@ -3240,6 +3240,7 @@ static void bss_compute_security(struct g_supplicant_bss *bss)
 #if defined TIZEN_EXT
        bss->ft_ieee8021x = FALSE;
        bss->ft_psk = FALSE;
+       GSupplicantInterface *interface = bss->interface;
 #endif
 
 #if defined TIZEN_EXT
@@ -3293,9 +3294,14 @@ static void bss_compute_security(struct g_supplicant_bss *bss)
 #if defined TIZEN_EXT
        else if (bss->ft_ieee8021x)
                bss->security = G_SUPPLICANT_SECURITY_IEEE8021X;
-       else if (bss->sae)
-               bss->security = G_SUPPLICANT_SECURITY_SAE;
-       else if (bss->psk_sha256)
+       else if (bss->sae) {
+               if (!bss->psk)
+                       bss->security = G_SUPPLICANT_SECURITY_SAE;
+               else if (interface->keymgmt_capa & G_SUPPLICANT_KEYMGMT_SAE)
+                       bss->security = G_SUPPLICANT_SECURITY_SAE;
+               else
+                       bss->security = G_SUPPLICANT_SECURITY_PSK;
+       } else if (bss->psk_sha256)
                bss->security = G_SUPPLICANT_SECURITY_PSK_SHA256;
 #endif
        else if (bss->psk)
@@ -7704,6 +7710,7 @@ static void crypt_method_call_cancel(void)
        }
 
        g_free(decrypt_request_data.data->path);
+       g_free(decrypt_request_data.data->ssid->ssid);
        g_free(decrypt_request_data.data->ssid);
        dbus_free(decrypt_request_data.data);
        decrypt_request_data.data = NULL;
@@ -7721,6 +7728,11 @@ static void decryption_request_reply(DBusPendingCall *call,
 
        SUPPLICANT_DBG("");
 
+       if (!decrypt_request_data.data) {
+               SUPPLICANT_DBG("decryption request is canceled");
+               return;
+       }
+
        reply = dbus_pending_call_steal_reply(call);
 
        dbus_error_init(&error);
@@ -8243,9 +8255,15 @@ static void interface_disconnect_result(const char *error,
        }
 }
 
+#if defined TIZEN_EXT
+int g_supplicant_interface_disconnect(GSupplicantInterface *interface,
+                                       GSupplicantInterfaceCallback callback,
+                                       void *user_data, void *connman_network)
+#else
 int g_supplicant_interface_disconnect(GSupplicantInterface *interface,
                                        GSupplicantInterfaceCallback callback,
                                                        void *user_data)
+#endif
 {
        struct interface_data *data;
        int ret;
@@ -8260,7 +8278,7 @@ int g_supplicant_interface_disconnect(GSupplicantInterface *interface,
 #if defined TIZEN_EXT
        if (decrypt_request_data.pending_call &&
                        decrypt_request_data.data &&
-                       decrypt_request_data.data->user_data == user_data) {
+                       decrypt_request_data.data->user_data == connman_network) {
 
                callback_assoc_failed(decrypt_request_data.data->user_data);
                crypt_method_call_cancel();