Browse Source

P2PS: Fix org.wi-fi.wfds matching when building the response

The service hash for org.wi-fi.wfds is supposed to match only if the
device has a WFA defined org.wi-fi.wfds.* service. Verify that before
adding org.wi-fi.wfds to the response.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
Jouni Malinen 9 years ago
parent
commit
509f269bbd
1 changed files with 16 additions and 1 deletions
  1. 16 1
      src/p2p/p2p_build.c

+ 16 - 1
src/p2p/p2p_build.c

@@ -420,6 +420,20 @@ static int p2ps_wildcard_hash(struct p2p_data *p2p,
 }
 
 
+static int p2p_wfa_service_adv(struct p2p_data *p2p)
+{
+	struct p2ps_advertisement *adv;
+
+	for (adv = p2p->p2ps_adv_list; adv; adv = adv->next) {
+		if (os_strncmp(adv->svc_name, P2PS_WILD_HASH_STR,
+			       os_strlen(P2PS_WILD_HASH_STR)) == 0)
+			return 1;
+	}
+
+	return 0;
+}
+
+
 static int p2p_buf_add_service_info(struct wpabuf *buf, struct p2p_data *p2p,
 				    u32 adv_id, u16 config_methods,
 				    const char *svc_name, u8 **ie_len, u8 **pos,
@@ -553,7 +567,8 @@ void p2p_buf_add_service_instance(struct wpabuf *buf, struct p2p_data *p2p,
 
 	wpa_hexdump(MSG_DEBUG, "P2PS: Probe Request service hash values",
 		    hash, hash_count * P2PS_HASH_LEN);
-	p2ps_wildcard = p2ps_wildcard_hash(p2p, hash, hash_count);
+	p2ps_wildcard = p2ps_wildcard_hash(p2p, hash, hash_count) &&
+		p2p_wfa_service_adv(p2p);
 
 	/* Allocate temp buffer, allowing for overflow of 1 instance */
 	tmp_buf = wpabuf_alloc(MAX_SVC_ADV_IE_LEN + 256 + P2PS_HASH_LEN);