From f4d28ce6399d33708ca96d3f8fc585f6fa47296f Mon Sep 17 00:00:00 2001 From: Stefano Avallone Date: Sun, 16 Apr 2023 18:58:50 +0200 Subject: [PATCH] wifi: Fix WifiInformationElement equality operator The size returned by GetInformationFieldSize() includes the Element ID Extension, but SerializeInformationField() does not serialize this field, thus the last byte of the buffers used by the equality operator are left uninitialized and the result of the comparison is random. Use GetSerializedSize() and Serialize() instead, which also work in case of fragmented Information Elements. --- src/wifi/model/wifi-information-element.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/wifi/model/wifi-information-element.cc b/src/wifi/model/wifi-information-element.cc index b2654ced7..6c4916164 100644 --- a/src/wifi/model/wifi-information-element.cc +++ b/src/wifi/model/wifi-information-element.cc @@ -238,25 +238,25 @@ WifiInformationElement::operator==(const WifiInformationElement& a) const return false; } - if (GetInformationFieldSize() != a.GetInformationFieldSize()) - { - return false; - } - if (ElementIdExt() != a.ElementIdExt()) { return false; } - uint32_t ieSize = GetInformationFieldSize(); + uint32_t ieSize = GetSerializedSize(); + + if (ieSize != a.GetSerializedSize()) + { + return false; + } Buffer myIe; Buffer hisIe; myIe.AddAtEnd(ieSize); hisIe.AddAtEnd(ieSize); - SerializeInformationField(myIe.Begin()); - a.SerializeInformationField(hisIe.Begin()); + Serialize(myIe.Begin()); + a.Serialize(hisIe.Begin()); return (memcmp(myIe.PeekData(), hisIe.PeekData(), ieSize) == 0); }