From ebdc32f350f8e3aa96d469ec9a4c902fa2dace92 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 18 Jun 2015 17:11:27 +0300 Subject: [PATCH] P2PS: Fix service hash matching for org.wi-fi.wfds 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 --- src/p2p/p2p.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/p2p/p2p.c b/src/p2p/p2p.c index 271b9ea..ad501ce 100644 --- a/src/p2p/p2p.c +++ b/src/p2p/p2p.c @@ -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; } -- 2.1.4