]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
P2P: Verify operating channel validity for NFC connection handover
authorJouni Malinen <jouni@qca.qualcomm.com>
Fri, 25 Apr 2014 20:09:56 +0000 (23:09 +0300)
committerJouni Malinen <j@w1.fi>
Tue, 29 Apr 2014 09:52:10 +0000 (12:52 +0300)
p2p_freq_to_channel() could return an error if the GO or P2P Client
operating channel is not valid. Check for this before generating the NFC
handover message.

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

index bcc7e64465808d88cc51b0c697b45febc1078f89..ea82ae83590be987471a5ce3fbfd22fe15675e81 100644 (file)
@@ -4463,12 +4463,24 @@ static struct wpabuf * p2p_build_nfc_handover(struct p2p_data *p2p,
        p2p_buf_add_device_info(buf, p2p, NULL);
 
        if (p2p->num_groups > 0) {
+               int freq = p2p_group_get_freq(p2p->groups[0]);
                role = P2P_GO_IN_A_GROUP;
-               p2p_freq_to_channel(p2p_group_get_freq(p2p->groups[0]),
-                                   &op_class, &channel);
+               if (p2p_freq_to_channel(freq, &op_class, &channel) < 0) {
+                       p2p_dbg(p2p,
+                               "Unknown GO operating frequency %d MHz for NFC handover",
+                               freq);
+                       wpabuf_free(buf);
+                       return NULL;
+               }
        } else if (client_freq > 0) {
                role = P2P_CLIENT_IN_A_GROUP;
-               p2p_freq_to_channel(client_freq, &op_class, &channel);
+               if (p2p_freq_to_channel(client_freq, &op_class, &channel) < 0) {
+                       p2p_dbg(p2p,
+                               "Unknown client operating frequency %d MHz for NFC handover",
+                               client_freq);
+                       wpabuf_free(buf);
+                       return NULL;
+               }
        }
 
        p2p_buf_add_oob_go_neg_channel(buf, p2p->cfg->country, op_class,