mirror of
https://github.com/espressif/openthread.git
synced 2026-08-07 19:27:46 +00:00
[mac] check frame length before reading security header (#2015)
This commit is contained in:
@@ -176,11 +176,12 @@ otError Frame::InitMacHeader(uint16_t aFcf, uint8_t aSecurityControl)
|
||||
otError Frame::ValidatePsdu(void)
|
||||
{
|
||||
otError error = OT_ERROR_PARSE;
|
||||
uint8_t offset = 0;
|
||||
uint16_t fcf;
|
||||
uint8_t offset = kFcfSize + kDsnSize;
|
||||
uint8_t footerLength = kFcsSize;
|
||||
uint16_t fcf;
|
||||
|
||||
VerifyOrExit((offset + footerLength) <= GetPsduLength());
|
||||
|
||||
VerifyOrExit((offset += kFcfSize + kDsnSize) <= GetPsduLength());
|
||||
fcf = static_cast<uint16_t>((GetPsdu()[1] << 8) | GetPsdu()[0]);
|
||||
|
||||
// Destinatinon PAN + Address
|
||||
@@ -229,6 +230,8 @@ otError Frame::ValidatePsdu(void)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
VerifyOrExit((offset + footerLength) <= GetPsduLength());
|
||||
|
||||
// Security Header
|
||||
if (fcf & Frame::kFcfSecurityEnabled)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user