[meshcop-leader] check IsLeader() processing `LeaderPetition/KeepAlive (#9531)

This commit adds an `IsLeader()` check to ensure that the device is
acting as the leader before processing `kUriLeaderPetition` or
`kUriLeaderKeepAlive` TMF messages. This adds a safeguard to ensure
that only the leader can update the commissioner dataset.
This commit is contained in:
Abtin Keshavarzian
2023-10-13 17:57:01 -07:00
committed by GitHub
parent 3e18032d2f
commit d5697604d0
+4
View File
@@ -73,6 +73,8 @@ template <> void Leader::HandleTmf<kUriLeaderPetition>(Coap::Message &aMessage,
LogInfo("Received %s", UriToString<kUriLeaderPetition>());
VerifyOrExit(Get<Mle::MleRouter>().IsLeader());
VerifyOrExit(Get<Mle::MleRouter>().IsRoutingLocator(aMessageInfo.GetPeerAddr()));
SuccessOrExit(Tlv::FindTlv(aMessage, commissionerId));
@@ -152,6 +154,8 @@ template <> void Leader::HandleTmf<kUriLeaderKeepAlive>(Coap::Message &aMessage,
LogInfo("Received %s", UriToString<kUriLeaderKeepAlive>());
VerifyOrExit(Get<Mle::MleRouter>().IsLeader());
SuccessOrExit(Tlv::Find<StateTlv>(aMessage, state));
SuccessOrExit(Tlv::Find<CommissionerSessionIdTlv>(aMessage, sessionId));