]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
BSS: Use variable length array for IEs at the end of struct wpa_bss
authorJouni Malinen <jouni@codeaurora.org>
Mon, 16 Nov 2020 14:25:17 +0000 (16:25 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 16 Nov 2020 14:25:17 +0000 (16:25 +0200)
Replace the previously used design "(u8 *) (bss + 1)" with a variable
length array at the end of struct wpa_bss bss->ies[] in hopes of making
this easier to understand for static analyzers.

Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
wpa_supplicant/bss.c
wpa_supplicant/bss.h

index 93ef6fe145296139e7e83185e95f1f8112e9b5bd..e9c2f822caee019897a8547539a3befd99b2ed40 100644 (file)
@@ -464,7 +464,7 @@ static struct wpa_bss * wpa_bss_add(struct wpa_supplicant *wpa_s,
        bss->ssid_len = ssid_len;
        bss->ie_len = res->ie_len;
        bss->beacon_ie_len = res->beacon_ie_len;
-       os_memcpy(bss + 1, res + 1, res->ie_len + res->beacon_ie_len);
+       os_memcpy(bss->ies, res + 1, res->ie_len + res->beacon_ie_len);
        wpa_bss_set_hessid(bss);
 
        if (wpa_s->num_bss + 1 > wpa_s->conf->bss_max_count &&
@@ -691,7 +691,7 @@ wpa_bss_update(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
 #endif /* CONFIG_P2P */
        if (bss->ie_len + bss->beacon_ie_len >=
            res->ie_len + res->beacon_ie_len) {
-               os_memcpy(bss + 1, res + 1, res->ie_len + res->beacon_ie_len);
+               os_memcpy(bss->ies, res + 1, res->ie_len + res->beacon_ie_len);
                bss->ie_len = res->ie_len;
                bss->beacon_ie_len = res->beacon_ie_len;
        } else {
@@ -712,7 +712,7 @@ wpa_bss_update(struct wpa_supplicant *wpa_s, struct wpa_bss *bss,
                                wpa_s->current_bss = nbss;
                        wpa_bss_update_pending_connect(wpa_s, bss, nbss);
                        bss = nbss;
-                       os_memcpy(bss + 1, res + 1,
+                       os_memcpy(bss->ies, res + 1,
                                  res->ie_len + res->beacon_ie_len);
                        bss->ie_len = res->ie_len;
                        bss->beacon_ie_len = res->beacon_ie_len;
index a918bc35633fd6d1769630256d555ce9cb6a5b0b..c68a3e5763efe4aae7592a0275a0e7c49d592225 100644 (file)
@@ -111,11 +111,12 @@ struct wpa_bss {
        size_t beacon_ie_len;
        /* followed by ie_len octets of IEs */
        /* followed by beacon_ie_len octets of IEs */
+       u8 ies[];
 };
 
 static inline const u8 * wpa_bss_ie_ptr(const struct wpa_bss *bss)
 {
-       return (const u8 *) (bss + 1);
+       return bss->ies;
 }
 
 void wpa_bss_update_start(struct wpa_supplicant *wpa_s);