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.
This commit is contained in:
Stefano Avallone
2023-04-16 18:58:50 +02:00
committed by Stefano Avallone
parent a7dd40b567
commit f4d28ce639

View File

@@ -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);
}