From 78b153f90a74fde4fe63698ac230fbefd2b369dc Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Fri, 25 Aug 2023 22:08:44 +0300 Subject: [PATCH] Calculate defragmented FTE length during IE parsing Get rid of the warning about unrecognized Fragment element when FTE is fragmented and make the total length of the FTE itself and the following Fragment elements available. For now, use a separate variable for the total length to avoid confusing existing callers. Signed-off-by: Jouni Malinen --- src/common/ieee802_11_common.c | 9 +++++++++ src/common/ieee802_11_common.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/common/ieee802_11_common.c b/src/common/ieee802_11_common.c index a8f16b3d1..d603f2633 100644 --- a/src/common/ieee802_11_common.c +++ b/src/common/ieee802_11_common.c @@ -421,6 +421,7 @@ static ParseRes __ieee802_11_parse_elems(const u8 *start, size_t len, for_each_element(elem, start, len) { u8 id = elem->id, elen = elem->datalen; const u8 *pos = elem->data; + size_t *total_len = NULL; if (id == WLAN_EID_FRAGMENT && elems->num_frag_elems > 0) { elems->num_frag_elems--; @@ -504,6 +505,8 @@ static ParseRes __ieee802_11_parse_elems(const u8 *start, size_t len, break; elems->ftie = pos; elems->ftie_len = elen; + elems->fte_defrag_len = elen; + total_len = &elems->fte_defrag_len; break; case WLAN_EID_TIMEOUT_INTERVAL: if (elen != 5) @@ -649,6 +652,12 @@ static ParseRes __ieee802_11_parse_elems(const u8 *start, size_t len, id, elen); break; } + + if (elen == 255 && total_len) + *total_len += ieee802_11_fragments_length( + elems, pos + elen, + (start + len) - (pos + elen)); + } if (!for_each_element_completed(elem, start, len)) { diff --git a/src/common/ieee802_11_common.h b/src/common/ieee802_11_common.h index 785fe608a..f8cede008 100644 --- a/src/common/ieee802_11_common.h +++ b/src/common/ieee802_11_common.h @@ -174,6 +174,8 @@ struct ieee802_11_elems { struct mb_ies_info mb_ies; + size_t fte_defrag_len; + /* * The number of fragment elements to be skipped after a known * fragmented element.