]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
TDLS: Avoid unnecessary copying of the Link Identifier element
authorJouni Malinen <j@w1.fi>
Sun, 17 Dec 2023 09:51:35 +0000 (11:51 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 17 Dec 2023 09:51:35 +0000 (11:51 +0200)
This memcpy was causing warnings from static analyzers since it is being
misinterpreted as copying all the data into the lnkid.bssid[] array
instead of that and the following arrays. Since the copy is not needed
at all, just use the original pointer to get rid of these warnings.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/rsn_supp/tdls.c

index e6f5877d298b49d67c1d5d459aebf857b9408166..47b1cd45ea87afd525d440bac976f3da6561a935 100644 (file)
@@ -3187,7 +3187,7 @@ int wpa_tdls_process_discovery_response(struct wpa_sm *sm, const u8 *addr,
                                        const u8 *buf, size_t len)
 {
        struct ieee802_11_elems elems;
-       struct wpa_tdls_lnkid lnkid;
+       const struct wpa_tdls_lnkid *lnkid;
        struct wpa_tdls_peer *peer;
        size_t min_req_len = 1 /* Dialog Token */ + 2 /* Capability */ +
                sizeof(struct wpa_tdls_lnkid);
@@ -3217,12 +3217,12 @@ int wpa_tdls_process_discovery_response(struct wpa_sm *sm, const u8 *addr,
                return -1;
        }
 
-       os_memcpy(&lnkid.bssid[0], elems.link_id, sizeof(lnkid) - 2);
+       lnkid = (const struct wpa_tdls_lnkid *) (elems.link_id - 2);
 
-       if (!wpa_tdls_is_lnkid_bss_valid(sm, &lnkid, &link_id)) {
+       if (!wpa_tdls_is_lnkid_bss_valid(sm, lnkid, &link_id)) {
                wpa_printf(MSG_DEBUG,
                           "TDLS: Discovery Response from different BSS "
-                          MACSTR, MAC2STR(lnkid.bssid));
+                          MACSTR, MAC2STR(lnkid->bssid));
                return -1;
        }
 
@@ -3234,7 +3234,7 @@ int wpa_tdls_process_discovery_response(struct wpa_sm *sm, const u8 *addr,
 
        peer->mld_link_id = link_id;
        wpa_printf(MSG_DEBUG, "TDLS: Link identifier BSS: " MACSTR
-                  " , link id: %u", MAC2STR(lnkid.bssid), link_id);
+                  " , link id: %u", MAC2STR(lnkid->bssid), link_id);
 
        return 0;
 }