TDLS: Avoid unnecessary copying of the Link Identifier element

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>
This commit is contained in:
Jouni Malinen 2023-12-17 11:51:35 +02:00
parent 656cf50d8b
commit 88bc6711a7

View file

@ -3187,7 +3187,7 @@ int wpa_tdls_process_discovery_response(struct wpa_sm *sm, const u8 *addr,
const u8 *buf, size_t len) const u8 *buf, size_t len)
{ {
struct ieee802_11_elems elems; struct ieee802_11_elems elems;
struct wpa_tdls_lnkid lnkid; const struct wpa_tdls_lnkid *lnkid;
struct wpa_tdls_peer *peer; struct wpa_tdls_peer *peer;
size_t min_req_len = 1 /* Dialog Token */ + 2 /* Capability */ + size_t min_req_len = 1 /* Dialog Token */ + 2 /* Capability */ +
sizeof(struct wpa_tdls_lnkid); sizeof(struct wpa_tdls_lnkid);
@ -3217,12 +3217,12 @@ int wpa_tdls_process_discovery_response(struct wpa_sm *sm, const u8 *addr,
return -1; 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, wpa_printf(MSG_DEBUG,
"TDLS: Discovery Response from different BSS " "TDLS: Discovery Response from different BSS "
MACSTR, MAC2STR(lnkid.bssid)); MACSTR, MAC2STR(lnkid->bssid));
return -1; 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; peer->mld_link_id = link_id;
wpa_printf(MSG_DEBUG, "TDLS: Link identifier BSS: " MACSTR 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; return 0;
} }