P2P: Fix association with an AP/P2P GO that is not a P2P manager
[mech_eap.git] / src / p2p / p2p.c
index f584fae..c02044b 100644 (file)
@@ -778,6 +778,7 @@ int p2p_add_device(struct p2p_data *p2p, const u8 *addr, int freq,
        if (os_memcmp(addr, p2p_dev_addr, ETH_ALEN) != 0)
                os_memcpy(dev->interface_addr, addr, ETH_ALEN);
        if (msg.ssid &&
+           msg.ssid[1] <= sizeof(dev->oper_ssid) &&
            (msg.ssid[1] != P2P_WILDCARD_SSID_LEN ||
             os_memcmp(msg.ssid + 2, P2P_WILDCARD_SSID, P2P_WILDCARD_SSID_LEN)
             != 0)) {
@@ -2484,10 +2485,21 @@ static int p2p_assoc_req_ie_wlan_ap(struct p2p_data *p2p, const u8 *bssid,
        size_t tmplen;
        int res;
        u8 group_capab;
+       struct p2p_message msg;
 
        if (p2p_ie == NULL)
                return 0; /* WLAN AP is not a P2P manager */
 
+       os_memset(&msg, 0, sizeof(msg));
+       if (p2p_parse_p2p_ie(p2p_ie, &msg) < 0)
+               return 0;
+
+       p2p_dbg(p2p, "BSS P2P manageability %s",
+               msg.manageability ? "enabled" : "disabled");
+
+       if (!msg.manageability)
+               return 0;
+
        /*
         * (Re)Association Request - P2P IE
         * P2P Capability attribute (shall be present)