Remove disconnected APs from BSS table if likely out-of-range
[mech_eap.git] / wpa_supplicant / wifi_display.c
index 6dc41de..c363b21 100644 (file)
@@ -233,15 +233,31 @@ int wifi_display_subelem_set(struct wpa_global *global, char *cmd)
        if (pos == NULL)
                return -1;
        *pos++ = '\0';
-       subelem = atoi(cmd);
-       if (subelem < 0 || subelem >= MAX_WFD_SUBELEMS)
-               return -1;
 
        len = os_strlen(pos);
        if (len & 1)
                return -1;
        len /= 2;
 
+       if (os_strcmp(cmd, "all") == 0) {
+               int res;
+
+               e = wpabuf_alloc(len);
+               if (e == NULL)
+                       return -1;
+               if (hexstr2bin(pos, wpabuf_put(e, len), len) < 0) {
+                       wpabuf_free(e);
+                       return -1;
+               }
+               res = wifi_display_subelem_set_from_ies(global, e);
+               wpabuf_free(e);
+               return res;
+       }
+
+       subelem = atoi(cmd);
+       if (subelem < 0 || subelem >= MAX_WFD_SUBELEMS)
+               return -1;
+
        if (len == 0) {
                /* Clear subelement */
                e = NULL;
@@ -271,7 +287,7 @@ int wifi_display_subelem_set_from_ies(struct wpa_global *global,
 {
        int subelements[MAX_WFD_SUBELEMS] = {};
        const u8 *pos, *end;
-       int len, subelem;
+       unsigned int len, subelem;
        struct wpabuf *e;
 
        wpa_printf(MSG_DEBUG, "WFD IEs set: %p - %lu",
@@ -292,7 +308,7 @@ int wifi_display_subelem_set_from_ies(struct wpa_global *global,
                wpa_printf(MSG_DEBUG, "WFD Sub-Element ID %d - len %d",
                           *pos, len - 3);
 
-               if (pos + len > end)
+               if (len > (unsigned int) (end - pos))
                        break;
 
                subelem = *pos;
@@ -325,6 +341,19 @@ int wifi_display_subelem_get(struct wpa_global *global, char *cmd,
 {
        int subelem;
 
+       if (os_strcmp(cmd, "all") == 0) {
+               struct wpabuf *ie;
+               int res;
+
+               ie = wifi_display_get_wfd_ie(global);
+               if (ie == NULL)
+                       return 0;
+               res = wpa_snprintf_hex(buf, buflen, wpabuf_head(ie),
+                                      wpabuf_len(ie));
+               wpabuf_free(ie);
+               return res;
+       }
+
        subelem = atoi(cmd);
        if (subelem < 0 || subelem >= MAX_WFD_SUBELEMS)
                return -1;