From 23bb9828a3a0b6a03f3fe4b7a2844ac5c4084794 Mon Sep 17 00:00:00 2001 From: Andrei Otcheretianski Date: Thu, 2 Jul 2015 10:45:04 +0300 Subject: [PATCH] P2PS: Fix P2PS-PROV-DONE event on GO If after P2PS PD the device should become a GO it sends P2PS-PROV-DONE event which contains the GO interface name. If the GO isn't running yet the device may use pending interface name. However, when the GO is started, pending interface name will be removed. Fix the GO interface name in P2PS-PROV-DONE event by copying the interface name instead of saving the pointer. Signed-off-by: Andrei Otcheretianski Reviewed-by: Ilan Peer --- wpa_supplicant/p2p_supplicant.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index aeaa114..c44ebfe 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -3738,16 +3738,26 @@ static void wpas_p2ps_prov_complete(void *ctx, u8 status, const u8 *dev, } if (conncap == P2PS_SETUP_GROUP_OWNER) { - const char *go_ifname = NULL; + /* + * We need to copy the interface name. Simply saving a + * pointer isn't enough, since if we use pending_interface_name + * it will be overwritten when the group is added. + */ + char go_ifname[100]; + + go_ifname[0] = '\0'; if (!go_wpa_s) { wpa_s->global->pending_p2ps_group = 1; if (!wpas_p2p_create_iface(wpa_s)) - go_ifname = wpa_s->ifname; + os_memcpy(go_ifname, wpa_s->ifname, + sizeof(go_ifname)); else if (wpa_s->pending_interface_name[0]) - go_ifname = wpa_s->pending_interface_name; + os_memcpy(go_ifname, + wpa_s->pending_interface_name, + sizeof(go_ifname)); - if (!go_ifname) { + if (!go_ifname[0]) { wpas_p2ps_prov_complete( wpa_s, P2P_SC_FAIL_UNKNOWN_GROUP, dev, adv_mac, ses_mac, @@ -3777,7 +3787,8 @@ static void wpas_p2ps_prov_complete(void *ctx, u8 status, const u8 *dev, MAC2STR(dev)); } } else if (passwd_id == DEV_PW_P2PS_DEFAULT) { - go_ifname = go_wpa_s->ifname; + os_memcpy(go_ifname, go_wpa_s->ifname, + sizeof(go_ifname)); wpa_dbg(go_wpa_s, MSG_DEBUG, "P2P: Setting PIN-1 For " MACSTR, MAC2STR(dev)); -- 2.1.4