]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2PS: Fix service hash matching for org.wi-fi.wfds
authorJouni Malinen <jouni@qca.qualcomm.com>
Thu, 18 Jun 2015 14:11:27 +0000 (17:11 +0300)
committerJouni Malinen <j@w1.fi>
Thu, 18 Jun 2015 14:27:31 +0000 (17:27 +0300)
This "wildcard" match is for WFA specified org.wi-fi.wfds.* services,
not for all services. Verify that there is a really matching service
being advertised instead of assuming this "wildcard" matches if any
services are advertised.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/p2p/p2p.c

index 271b9eab4f43d5c67769a1d557890ded68f14129..ad501ce03c65cf6d1ae41e1d8c47babd38334c07 100644 (file)
@@ -2226,18 +2226,21 @@ struct wpabuf * p2p_build_probe_resp_ies(struct p2p_data *p2p,
 static int p2p_service_find_asp(struct p2p_data *p2p, const u8 *hash)
 {
        struct p2ps_advertisement *adv_data;
+       int any_wfa;
 
        p2p_dbg(p2p, "ASP find - ASP list: %p", p2p->p2ps_adv_list);
 
-       /* Wildcard always matches if we have actual services */
-       if (os_memcmp(hash, p2p->wild_card_hash, P2PS_HASH_LEN) == 0)
-               return p2p->p2ps_adv_list != NULL;
+       /* Wildcard org.wi-fi.wfds matches any WFA spec defined service */
+       any_wfa = os_memcmp(hash, p2p->wild_card_hash, P2PS_HASH_LEN) == 0;
 
        adv_data = p2p->p2ps_adv_list;
        while (adv_data) {
-               p2p_dbg(p2p, "ASP hash: %x =? %x", hash[0], adv_data->hash[0]);
                if (os_memcmp(hash, adv_data->hash, P2PS_HASH_LEN) == 0)
-                       return 1;
+                       return 1; /* exact hash match */
+               if (any_wfa &&
+                   os_strncmp(adv_data->svc_name, P2PS_WILD_HASH_STR,
+                              os_strlen(P2PS_WILD_HASH_STR)) == 0)
+                       return 1; /* WFA service match */
                adv_data = adv_data->next;
        }