From 34cb1b7d40ee0eef5bd783aa9b5dd2d5f728ec27 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Sat, 13 Mar 2021 08:36:00 -0800 Subject: [PATCH] [mac-frame] return parse error in GetKeyId() (#6281) --- src/core/mac/mac_frame.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/core/mac/mac_frame.cpp b/src/core/mac/mac_frame.cpp index e79531cc5..134d8e1de 100644 --- a/src/core/mac/mac_frame.cpp +++ b/src/core/mac/mac_frame.cpp @@ -564,7 +564,7 @@ Error Frame::GetKeyId(uint8_t &aKeyId) const uint8_t keySourceLength; uint8_t index = FindSecurityHeaderIndex(); - VerifyOrExit(index != kInvalidIndex); + VerifyOrExit(index != kInvalidIndex, error = kErrorParse); keySourceLength = GetKeySourceLength(mPsdu[index] & kKeyIdModeMask); @@ -590,6 +590,7 @@ Error Frame::GetCommandId(uint8_t &aCommandId) const { Error error = kErrorNone; uint8_t index = FindPayloadIndex(); + VerifyOrExit(index != kInvalidIndex, error = kErrorParse); aCommandId = mPsdu[IsVersion2015() ? index : (index - 1)];