From af4103e5e94a7f4bd7a1f587840fc701ca821e7b Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 23 Nov 2017 23:32:33 +0200 Subject: [PATCH] DPP: Provide peer_mac to PKEX Initiator through function argument Avoid unnecessary direct write to a struct dpp_pkex member from outside dpp.c. Signed-off-by: Jouni Malinen --- src/ap/dpp_hostapd.c | 3 +-- src/common/dpp.c | 3 +++ src/common/dpp.h | 1 + wpa_supplicant/dpp_supplicant.c | 3 +-- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ap/dpp_hostapd.c b/src/ap/dpp_hostapd.c index 7beb5ba5a..2f8355f6d 100644 --- a/src/ap/dpp_hostapd.c +++ b/src/ap/dpp_hostapd.c @@ -1198,8 +1198,7 @@ hostapd_dpp_rx_pkex_exchange_resp(struct hostapd_data *hapd, const u8 *src, return; } - os_memcpy(hapd->dpp_pkex->peer_mac, src, ETH_ALEN); - msg = dpp_pkex_rx_exchange_resp(hapd->dpp_pkex, buf, len); + msg = dpp_pkex_rx_exchange_resp(hapd->dpp_pkex, src, buf, len); if (!msg) { wpa_printf(MSG_DEBUG, "DPP: Failed to process the response"); return; diff --git a/src/common/dpp.c b/src/common/dpp.c index 07fa9a3dc..54a5a6c7d 100644 --- a/src/common/dpp.c +++ b/src/common/dpp.c @@ -6671,6 +6671,7 @@ fail: struct wpabuf * dpp_pkex_rx_exchange_resp(struct dpp_pkex *pkex, + const u8 *peer_mac, const u8 *buf, size_t buflen) { const u8 *attr_status, *attr_id, *attr_key, *attr_group; @@ -6693,6 +6694,8 @@ struct wpabuf * dpp_pkex_rx_exchange_resp(struct dpp_pkex *pkex, if (pkex->failed || pkex->t >= PKEX_COUNTER_T_LIMIT || !pkex->initiator) return NULL; + os_memcpy(pkex->peer_mac, peer_mac, ETH_ALEN); + attr_status = dpp_get_attr(buf, buflen, DPP_ATTR_STATUS, &attr_status_len); if (!attr_status || attr_status_len != 1) { diff --git a/src/common/dpp.h b/src/common/dpp.h index 2b73285f1..0a998c436 100644 --- a/src/common/dpp.h +++ b/src/common/dpp.h @@ -396,6 +396,7 @@ struct dpp_pkex * dpp_pkex_rx_exchange_req(void *msg_ctx, const char *code, const u8 *buf, size_t len); struct wpabuf * dpp_pkex_rx_exchange_resp(struct dpp_pkex *pkex, + const u8 *peer_mac, const u8 *buf, size_t len); struct wpabuf * dpp_pkex_rx_commit_reveal_req(struct dpp_pkex *pkex, const u8 *hdr, diff --git a/wpa_supplicant/dpp_supplicant.c b/wpa_supplicant/dpp_supplicant.c index 07f2e943e..f54429446 100644 --- a/wpa_supplicant/dpp_supplicant.c +++ b/wpa_supplicant/dpp_supplicant.c @@ -1796,8 +1796,7 @@ wpas_dpp_rx_pkex_exchange_resp(struct wpa_supplicant *wpa_s, const u8 *src, eloop_cancel_timeout(wpas_dpp_pkex_retry_timeout, wpa_s, NULL); wpa_s->dpp_pkex->exch_req_wait_time = 0; - os_memcpy(wpa_s->dpp_pkex->peer_mac, src, ETH_ALEN); - msg = dpp_pkex_rx_exchange_resp(wpa_s->dpp_pkex, buf, len); + msg = dpp_pkex_rx_exchange_resp(wpa_s->dpp_pkex, src, buf, len); if (!msg) { wpa_printf(MSG_DEBUG, "DPP: Failed to process the response"); return;