Check supported types in wpas_mac_addr_rand_scan_set()

When setting scan with randomized MAC, check the requested scan type
against supported types, to ensure callers will not set an unsupported
type, since this can cause scan/connect failures later. It is better to
do this in wpas_mac_addr_rand_scan_set() instead of control interface
specific code to apply the constraint on all possible interfaces using
this setting.

Signed-off-by: Lior David <liord@codeaurora.org>
This commit is contained in:
Lior David 2019-01-21 18:28:42 +02:00 committed by Jouni Malinen
parent c85249aa15
commit 1e591df063
2 changed files with 17 additions and 13 deletions

View File

@ -9527,13 +9527,6 @@ static int wpas_ctrl_iface_mac_rand_scan(struct wpa_supplicant *wpa_s,
return -1;
}
if ((wpa_s->mac_addr_rand_supported & type) != type) {
wpa_printf(MSG_INFO,
"CTRL: MAC_RAND_SCAN types=%u != supported=%u",
type, wpa_s->mac_addr_rand_supported);
return -1;
}
if (enable > 1) {
wpa_printf(MSG_INFO,
"CTRL: MAC_RAND_SCAN enable=<0/1> not specified");
@ -9567,21 +9560,25 @@ static int wpas_ctrl_iface_mac_rand_scan(struct wpa_supplicant *wpa_s,
}
if (type & MAC_ADDR_RAND_SCAN) {
wpas_mac_addr_rand_scan_set(wpa_s, MAC_ADDR_RAND_SCAN,
addr, mask);
if (wpas_mac_addr_rand_scan_set(wpa_s, MAC_ADDR_RAND_SCAN,
addr, mask))
return -1;
}
if (type & MAC_ADDR_RAND_SCHED_SCAN) {
wpas_mac_addr_rand_scan_set(wpa_s, MAC_ADDR_RAND_SCHED_SCAN,
addr, mask);
if (wpas_mac_addr_rand_scan_set(wpa_s, MAC_ADDR_RAND_SCHED_SCAN,
addr, mask))
return -1;
if (wpa_s->sched_scanning && !wpa_s->pno)
wpas_scan_restart_sched_scan(wpa_s);
}
if (type & MAC_ADDR_RAND_PNO) {
wpas_mac_addr_rand_scan_set(wpa_s, MAC_ADDR_RAND_PNO,
addr, mask);
if (wpas_mac_addr_rand_scan_set(wpa_s, MAC_ADDR_RAND_PNO,
addr, mask))
return -1;
if (wpa_s->pno) {
wpas_stop_pno(wpa_s);
wpas_start_pno(wpa_s);

View File

@ -2806,6 +2806,13 @@ int wpas_mac_addr_rand_scan_set(struct wpa_supplicant *wpa_s,
{
u8 *tmp = NULL;
if ((wpa_s->mac_addr_rand_supported & type) != type ) {
wpa_printf(MSG_INFO,
"scan: MAC randomization type %u != supported=%u",
type, wpa_s->mac_addr_rand_supported);
return -1;
}
wpas_mac_addr_rand_scan_clear(wpa_s, type);
if (addr) {