Skip to content

Commit

Permalink
[meshcop-leader] check IsLeader() processing `LeaderPetition/KeepAl…
Browse files Browse the repository at this point in the history
…ive (openthread#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.
  • Loading branch information
abtink authored Oct 14, 2023
1 parent 3e18032 commit d569760
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/meshcop/meshcop_leader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit d569760

Please sign in to comment.