Skip to content

Commit

Permalink
[cli] add validation of targetpower channel (openthread#11326)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwhui authored Mar 6, 2025
1 parent a470e8b commit 555454c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/cli/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6717,8 +6717,11 @@ template <> otError Interpreter::Process<Cmd("targetpower")>(Arg aArgs[])
uint32_t channelMask;

SuccessOrExit(error = aArgs[0].ParseAsUint8(channel));
VerifyOrExit(channel < BitSizeOf(channelMask), error = OT_ERROR_INVALID_ARGS);

channelMask = otLinkGetSupportedChannelMask(GetInstancePtr());
VerifyOrExit((1 << channel) & channelMask, error = OT_ERROR_INVALID_ARGS);

SuccessOrExit(error = aArgs[1].ParseAsInt16(targetPower));

error = otPlatRadioSetChannelTargetPower(GetInstancePtr(), channel, targetPower);
Expand Down

0 comments on commit 555454c

Please sign in to comment.