From 4284a0b1b03239b5ef0afb24c950233df25b409a Mon Sep 17 00:00:00 2001
From: Jouni Malinen <jouni@qca.qualcomm.com>
Date: Tue, 26 Feb 2013 17:22:11 +0200
Subject: [PATCH] P2P: Fail GO Negotiation on missing Group ID

The device that is selected as the GO shall incode P2P Group ID
attribute in GO Negotiation Response/Confirm message. Previously we did
not reject a message without that attribute since it was possible to
continue operations even without knowing the SSID. However, this can
potentially result in confusing results since missing P2P Group ID
attribute can be a sign of conflicting GO role determination (both
devices assuming the peer is the GO). To get clearer end result for the
GO Negotiation, reject this as a fatal error. In addition, stop GO
Negotiation if GO Negotiation Confirm indicates non-zero status since
that is also a fatal error.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>
---
 src/p2p/p2p_go_neg.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/p2p/p2p_go_neg.c b/src/p2p/p2p_go_neg.c
index 8811c8557..957e29f28 100644
--- a/src/p2p/p2p_go_neg.c
+++ b/src/p2p/p2p_go_neg.c
@@ -979,10 +979,8 @@ void p2p_process_go_neg_resp(struct p2p_data *p2p, const u8 *sa,
 			"P2P: Mandatory P2P Group ID attribute missing from "
 			"GO Negotiation Response");
 		p2p->ssid_len = 0;
-#ifdef CONFIG_P2P_STRICT
 		status = P2P_SC_FAIL_INVALID_PARAMS;
 		goto fail;
-#endif /* CONFIG_P2P_STRICT */
 	}
 
 	if (!msg.config_timeout) {
@@ -1112,6 +1110,11 @@ fail:
 		p2p_go_neg_failed(p2p, dev, -1);
 	}
 	wpabuf_free(conf);
+	if (status != P2P_SC_SUCCESS) {
+		wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
+			"P2P: GO Negotiation failed");
+		p2p_go_neg_failed(p2p, dev, status);
+	}
 }
 
 
@@ -1169,6 +1172,7 @@ void p2p_process_go_neg_conf(struct p2p_data *p2p, const u8 *sa,
 		wpa_msg(p2p->cfg->msg_ctx, MSG_DEBUG,
 			"P2P: GO Negotiation rejected: status %d",
 			*msg.status);
+		p2p_go_neg_failed(p2p, dev, *msg.status);
 		p2p_parse_free(&msg);
 		return;
 	}
@@ -1182,10 +1186,9 @@ void p2p_process_go_neg_conf(struct p2p_data *p2p, const u8 *sa,
 			"P2P: Mandatory P2P Group ID attribute missing from "
 			"GO Negotiation Confirmation");
 		p2p->ssid_len = 0;
-#ifdef CONFIG_P2P_STRICT
+		p2p_go_neg_failed(p2p, dev, P2P_SC_FAIL_INVALID_PARAMS);
 		p2p_parse_free(&msg);
 		return;
-#endif /* CONFIG_P2P_STRICT */
 	}
 
 	if (!msg.operating_channel) {