[mac] validate channel in Mac::SetChannel() (#2030)

This commit is contained in:
Jonathan Hui
2017-07-26 12:15:01 -07:00
committed by GitHub
parent f88c537c6c
commit 3e6dbe7cef
2 changed files with 8 additions and 2 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ otError otLinkSetChannel(otInstance *aInstance, uint8_t aChannel)
VerifyOrExit(aInstance->mThreadNetif.GetMle().GetRole() == OT_DEVICE_ROLE_DISABLED,
error = OT_ERROR_INVALID_STATE);
error = aInstance->mThreadNetif.GetMac().SetChannel(aChannel);
SuccessOrExit(error = aInstance->mThreadNetif.GetMac().SetChannel(aChannel));
aInstance->mThreadNetif.GetActiveDataset().Clear();
aInstance->mThreadNetif.GetPendingDataset().Clear();
+7 -1
View File
@@ -475,7 +475,12 @@ otError Mac::SetShortAddress(ShortAddress aShortAddress)
otError Mac::SetChannel(uint8_t aChannel)
{
otError error = OT_ERROR_NONE;
otLogFuncEntryMsg("%d", aChannel);
VerifyOrExit(OT_RADIO_CHANNEL_MIN <= aChannel && aChannel <= OT_RADIO_CHANNEL_MAX, error = OT_ERROR_INVALID_ARGS);
mChannel = aChannel;
if (mState == kStateIdle)
@@ -483,8 +488,9 @@ otError Mac::SetChannel(uint8_t aChannel)
NextOperation();
}
exit:
otLogFuncExit();
return OT_ERROR_NONE;
return error;
}
otError Mac::SetNetworkName(const char *aNetworkName)