From 88bc6711a74f5b57303612a73a2c5f4977c2f649 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sun, 17 Dec 2023 11:51:35 +0200 Subject: [PATCH] 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 --- src/rsn_supp/tdls.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/rsn_supp/tdls.c b/src/rsn_supp/tdls.c index e6f5877d2..47b1cd45e 100644 --- a/src/rsn_supp/tdls.c +++ b/src/rsn_supp/tdls.c @@ -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; }