mirror of
https://github.com/espressif/openthread.git
synced 2026-06-06 05:24:51 +00:00
[cli] add length check on dataset 'set' command (#5361)
This commit is contained in:
@@ -947,17 +947,21 @@ otError Dataset::ProcessSet(uint8_t aArgsLength, char *aArgs[])
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
otOperationalDatasetTlvs dataset;
|
||||
int tlvsLength;
|
||||
|
||||
VerifyOrExit(aArgsLength == 2, error = OT_ERROR_INVALID_ARGS);
|
||||
|
||||
tlvsLength = Interpreter::Hex2Bin(aArgs[1], dataset.mTlvs, sizeof(dataset.mTlvs));
|
||||
VerifyOrExit((0 <= tlvsLength) && (static_cast<size_t>(tlvsLength) <= sizeof(dataset.mTlvs)),
|
||||
error = OT_ERROR_INVALID_ARGS);
|
||||
dataset.mLength = static_cast<uint8_t>(tlvsLength);
|
||||
|
||||
if (strcmp(aArgs[0], "active") == 0)
|
||||
{
|
||||
dataset.mLength = static_cast<uint8_t>(Interpreter::Hex2Bin(aArgs[1], dataset.mTlvs, sizeof(dataset.mTlvs)));
|
||||
SuccessOrExit(error = otDatasetSetActiveTlvs(mInterpreter.mInstance, &dataset));
|
||||
}
|
||||
else if (strcmp(aArgs[0], "pending") == 0)
|
||||
{
|
||||
dataset.mLength = static_cast<uint8_t>(Interpreter::Hex2Bin(aArgs[1], dataset.mTlvs, sizeof(dataset.mTlvs)));
|
||||
SuccessOrExit(error = otDatasetSetPendingTlvs(mInterpreter.mInstance, &dataset));
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user