From ac21e00fa160988619c6a8a55967a92f436fb54b Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Fri, 4 Jun 2021 13:06:24 -0700 Subject: [PATCH] [mac] avoid potential assert with SetKeyId() on an invalid frame (#6704) --- src/core/mac/sub_mac.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/mac/sub_mac.cpp b/src/core/mac/sub_mac.cpp index fea69f28b..750c8d5fe 100644 --- a/src/core/mac/sub_mac.cpp +++ b/src/core/mac/sub_mac.cpp @@ -331,14 +331,14 @@ void SubMac::ProcessTransmitSecurity(void) VerifyOrExit(mTransmitFrame.GetSecurityEnabled()); VerifyOrExit(!mTransmitFrame.IsSecurityProcessed()); + SuccessOrExit(mTransmitFrame.GetKeyIdMode(keyIdMode)); + if (!mTransmitFrame.IsARetransmission()) { mTransmitFrame.SetKeyId(mKeyId); } VerifyOrExit(ShouldHandleTransmitSecurity()); - - SuccessOrExit(mTransmitFrame.GetKeyIdMode(keyIdMode)); VerifyOrExit(keyIdMode == Frame::kKeyIdMode1); mTransmitFrame.SetAesKey(GetCurrentMacKey());