From 1a554a300d73489213c137776c1da69b074303f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vivek=20Das=C2=A0Mohapatra?= Date: Sat, 5 Oct 2024 03:19:29 +0100 Subject: [PATCH] mpdu: tolerate technically illegal but harmless cloned IEs --- src/ie.h | 17 +++++++++++++++++ src/mpdu.c | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/src/ie.h b/src/ie.h index 4498785a..bc750696 100644 --- a/src/ie.h +++ b/src/ie.h @@ -598,6 +598,23 @@ static inline const unsigned char *ie_tlv_iter_get_data( return iter->data; } +static inline bool ie_tlv_iter_data_eq(struct ie_tlv_iter *a, + struct ie_tlv_iter *b) +{ + if (a == b) + return true; + + if (a == NULL || b == NULL) + return false; + + if (ie_tlv_iter_get_length(a) != ie_tlv_iter_get_length(b)) + return false; + + return memcmp(ie_tlv_iter_get_data(a), + ie_tlv_iter_get_data(b), + ie_tlv_iter_get_length(a)) == 0; +} + void *ie_tlv_extract_wsc_payload(const uint8_t *ies, size_t len, ssize_t *out_len); void *ie_tlv_encapsulate_wsc_payload(const uint8_t *data, size_t len, diff --git a/src/mpdu.c b/src/mpdu.c index 9d0409d2..f55866e1 100644 --- a/src/mpdu.c +++ b/src/mpdu.c @@ -398,9 +398,16 @@ static bool validate_mgmt_ies(const uint8_t *ies, size_t ies_len, memcpy(&clone, &iter, sizeof(clone)); + /* + * Some APs send completely identical duplicate IEs: + * Since these are harmless (and ignored by us) we're + * going to allow them here for interoperability. + */ while (ie_tlv_iter_next(&clone)) { if (ie_tlv_iter_get_tag(&clone) != tag) continue; + else if (ie_tlv_iter_data_eq(&iter, &clone)) + continue; return false; }