]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Check supported types in wpas_mac_addr_rand_scan_set()
authorLior David <liord@codeaurora.org>
Mon, 21 Jan 2019 16:28:42 +0000 (18:28 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 23 Jan 2019 22:21:34 +0000 (00:21 +0200)
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>
wpa_supplicant/ctrl_iface.c
wpa_supplicant/scan.c

index 7d38095e19bf3b5e3d285e4914317d0b89d29d05..7882dcf84f5de6a985b672c7a8ab8e7072d622cd 100644 (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);
index 52b521f93da0851d1b2dde569a7c60ed496f93ce..727c49ad4da9634061858aba5ab9d9657ebfdd24 100644 (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) {