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 <quic_jouni@quicinc.com>
This commit is contained in:
Jouni Malinen 2023-08-25 22:08:44 +03:00 committed by Jouni Malinen
parent aa08d9d768
commit 78b153f90a
2 changed files with 11 additions and 0 deletions

View file

@ -421,6 +421,7 @@ static ParseRes __ieee802_11_parse_elems(const u8 *start, size_t len,
for_each_element(elem, start, len) { for_each_element(elem, start, len) {
u8 id = elem->id, elen = elem->datalen; u8 id = elem->id, elen = elem->datalen;
const u8 *pos = elem->data; const u8 *pos = elem->data;
size_t *total_len = NULL;
if (id == WLAN_EID_FRAGMENT && elems->num_frag_elems > 0) { if (id == WLAN_EID_FRAGMENT && elems->num_frag_elems > 0) {
elems->num_frag_elems--; elems->num_frag_elems--;
@ -504,6 +505,8 @@ static ParseRes __ieee802_11_parse_elems(const u8 *start, size_t len,
break; break;
elems->ftie = pos; elems->ftie = pos;
elems->ftie_len = elen; elems->ftie_len = elen;
elems->fte_defrag_len = elen;
total_len = &elems->fte_defrag_len;
break; break;
case WLAN_EID_TIMEOUT_INTERVAL: case WLAN_EID_TIMEOUT_INTERVAL:
if (elen != 5) if (elen != 5)
@ -649,6 +652,12 @@ static ParseRes __ieee802_11_parse_elems(const u8 *start, size_t len,
id, elen); id, elen);
break; 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)) { if (!for_each_element_completed(elem, start, len)) {

View file

@ -174,6 +174,8 @@ struct ieee802_11_elems {
struct mb_ies_info mb_ies; struct mb_ies_info mb_ies;
size_t fte_defrag_len;
/* /*
* The number of fragment elements to be skipped after a known * The number of fragment elements to be skipped after a known
* fragmented element. * fragmented element.