mirror of
https://github.com/espressif/openthread.git
synced 2026-07-08 13:20:25 +00:00
[cli] add bounds check on channel selection (#3499)
This commit is contained in:
@@ -887,6 +887,7 @@ void Interpreter::ProcessDiscover(int argc, char *argv[])
|
||||
if (argc > 0)
|
||||
{
|
||||
SuccessOrExit(error = ParseLong(argv[0], value));
|
||||
VerifyOrExit(value <= static_cast<long>(sizeof(scanChannels) * CHAR_BIT), error = OT_ERROR_INVALID_ARGS);
|
||||
scanChannels = 1 << value;
|
||||
}
|
||||
|
||||
@@ -2729,6 +2730,7 @@ void Interpreter::ProcessScan(int argc, char *argv[])
|
||||
else
|
||||
{
|
||||
SuccessOrExit(error = ParseLong(argv[0], value));
|
||||
VerifyOrExit(value < static_cast<long>(sizeof(scanChannels) * CHAR_BIT), error = OT_ERROR_INVALID_ARGS);
|
||||
scanChannels = 1 << value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user