From patchwork Tue Nov 27 13:36:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [v2] WPS 2.0: Update authorized enrollee MAC address list correctly From: Amitkumar Karwar X-Patchwork-Id: 202222 Message-Id: <5FF020A1CFFEEC49BD1E09530C4FF5950CC73D6C03@SC-VEXCH1.marvell.com> To: "'hostap@lists.shmoo.com'" Cc: Bing Zhao Date: Tue, 27 Nov 2012 05:36:35 -0800 From: Amitkumar Karwar Sometimes both wildcard and specific MAC addresses are included by registrar in AuthorizedMACs subelement. This patch makes sure that only one of them will be present. Signed-off-by: Amitkumar Karwar --- v2: modify patch description (Jouni Malinen) src/wps/wps_registrar.c | 24 +++++++++++++++++++++--- 1 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/wps/wps_registrar.c b/src/wps/wps_registrar.c index d8e0d6f..d376f8d 100644 --- a/src/wps/wps_registrar.c +++ b/src/wps/wps_registrar.c @@ -198,6 +198,8 @@ static void wps_registrar_add_authorized_mac(struct wps_registrar *reg, const u8 *addr) { int i; + u8 bcast[ETH_ALEN] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; + wpa_printf(MSG_DEBUG, "WPS: Add authorized MAC " MACSTR, MAC2STR(addr)); for (i = 0; i < WPS_MAX_AUTHORIZED_MACS; i++) @@ -206,9 +208,25 @@ static void wps_registrar_add_authorized_mac(struct wps_registrar *reg, "already in the list"); return; /* already in list */ } - for (i = WPS_MAX_AUTHORIZED_MACS - 1; i > 0; i--) - os_memcpy(reg->authorized_macs[i], reg->authorized_macs[i - 1], - ETH_ALEN); + + if (os_memcmp(addr, bcast, ETH_ALEN) == 0) { + /* + * Clear authorized MAC address list while adding wildcard MAC + */ + for (i = 0; i < WPS_MAX_AUTHORIZED_MACS; i++) + os_memset(reg->authorized_macs[0], 0x00, ETH_ALEN); + } else { + /* Remove wildcard MAC when valid MAC address is added */ + if (os_memcmp(reg->authorized_macs[0], bcast, ETH_ALEN) == 0) { + os_memset(reg->authorized_macs[0], 0x00, ETH_ALEN); + } else { + for (i = WPS_MAX_AUTHORIZED_MACS - 1; i > 0; i--) + os_memcpy(reg->authorized_macs[i], + reg->authorized_macs[i - 1], + ETH_ALEN); + } + + } os_memcpy(reg->authorized_macs[0], addr, ETH_ALEN); wpa_hexdump(MSG_DEBUG, "WPS: Authorized MACs", (u8 *) reg->authorized_macs, sizeof(reg->authorized_macs));