]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P2: Remember password from connect command to starting after scan
authorShivani Baranwal <quic_shivbara@quicinc.com>
Wed, 3 Jul 2024 16:41:26 +0000 (22:11 +0530)
committerJouni Malinen <j@w1.fi>
Thu, 31 Oct 2024 11:57:55 +0000 (13:57 +0200)
The password for pairing setup needs to be kept in memory so that it can
be used once a scan for the GO has completed.

Signed-off-by: Shivani Baranwal <quic_shivbara@quicinc.com>
wpa_supplicant/p2p_supplicant.c
wpa_supplicant/wpa_supplicant_i.h

index b60588dbe8995add01cb78906dee0f085be0b290..f746c338be2ffd9a554fe068fee8fa535f219750 100644 (file)
@@ -5950,7 +5950,8 @@ static void wpas_p2p_scan_res_join(struct wpa_supplicant *wpa_s,
                                         NULL, 0,
                                         is_p2p_allow_6ghz(wpa_s->global->p2p),
                                         wpa_s->p2p2, wpa_s->p2p_bootstrap,
-                                        NULL);
+                                        wpa_s->pending_join_password[0] ?
+                                        wpa_s->pending_join_password : NULL);
                        return;
                }
 
@@ -6279,6 +6280,13 @@ static int wpas_p2p_join_start(struct wpa_supplicant *wpa_s, int freq,
        os_memcpy(res.peer_device_addr, wpa_s->pending_join_dev_addr, ETH_ALEN);
        os_memcpy(res.peer_interface_addr, wpa_s->pending_join_iface_addr,
                  ETH_ALEN);
+       if (wpa_s->pending_join_password[0]) {
+               res.akmp = WPA_KEY_MGMT_SAE;
+               os_strlcpy(res.sae_password, wpa_s->pending_join_password,
+                          sizeof(res.sae_password));
+               os_memset(wpa_s->pending_join_password, 0,
+                         sizeof(wpa_s->pending_join_password));
+       }
        res.wps_method = wpa_s->pending_join_wps_method;
        res.p2p2 = wpa_s->p2p2;
        res.cipher = WPA_CIPHER_CCMP;
@@ -6602,6 +6610,10 @@ int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
        } else
                wpa_s->p2p_pin[0] = '\0';
 
+       if (!password)
+               os_memset(wpa_s->pending_join_password, 0,
+                         sizeof(wpa_s->pending_join_password));
+
        if (join || auto_join) {
                u8 iface_addr[ETH_ALEN], dev_addr[ETH_ALEN];
                if (auth) {
@@ -6670,6 +6682,9 @@ int wpas_p2p_connect(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
                                   wpa_s->p2p_auto_started.usec);
                }
                wpa_s->user_initiated_pd = 1;
+               if (password)
+                       os_strlcpy(wpa_s->pending_join_password, password,
+                                  sizeof(wpa_s->pending_join_password));
                if (wpas_p2p_join(wpa_s, iface_addr, dev_addr, wps_method,
                                  auto_join, freq,
                                  group_ssid, group_ssid_len) < 0)
index 1f41c149e4a59eaf6c96cf15d0770b3b551eaf46..f497644b715d8abb09843455a474ea49507a0d3a 100644 (file)
@@ -1115,6 +1115,7 @@ struct wpa_supplicant {
        u8 pending_join_dev_addr[ETH_ALEN];
        u8 p2p_bootstrap_dev_addr[ETH_ALEN];
        int pending_join_wps_method;
+       char pending_join_password[100];
        u8 p2p_join_ssid[SSID_MAX_LEN];
        size_t p2p_join_ssid_len;
        int p2p_join_scan_count;