mirror of
https://github.com/espressif/openthread.git
synced 2026-08-18 08:29:52 +00:00
[mac] fix the Mac::NetworkName length check (length >= 1) (#7018)
This commit fixes the `NetworkName` check (for its length to be larger
than zero) which was recently added in commit e2f0afab5d. This commit
moves the name length check to method `Set(const NameData &aNameData)`
and after the `newLen` is calculated.
This commit also updates `TestMacNetworkName()` in unit test to verify
that setting the network name to an empty string correctly fails with
`kErrorInvalidArgs`.
This commit is contained in:
@@ -190,8 +190,7 @@ void TestMacNetworkName(void)
|
||||
SuccessOrQuit(networkName.Set(Mac::NameData(kName2, sizeof(kName2))));
|
||||
CompareNetworkName(networkName, kName2);
|
||||
|
||||
SuccessOrQuit(networkName.Set(Mac::NameData(kEmptyName, 0)));
|
||||
CompareNetworkName(networkName, kEmptyName);
|
||||
VerifyOrQuit(networkName.Set(Mac::NameData(kEmptyName, 0)) == kErrorInvalidArgs);
|
||||
|
||||
SuccessOrQuit(networkName.Set(Mac::NameData(kLongName, sizeof(kLongName))));
|
||||
CompareNetworkName(networkName, kLongName);
|
||||
@@ -199,8 +198,7 @@ void TestMacNetworkName(void)
|
||||
VerifyOrQuit(networkName.Set(Mac::NameData(kLongName, sizeof(kLongName) - 1)) == kErrorAlready,
|
||||
"failed to detect duplicate");
|
||||
|
||||
SuccessOrQuit(networkName.Set(Mac::NameData(nullptr, 0)));
|
||||
CompareNetworkName(networkName, kEmptyName);
|
||||
VerifyOrQuit(networkName.Set(kEmptyName) == kErrorInvalidArgs);
|
||||
|
||||
SuccessOrQuit(networkName.Set(Mac::NameData(kName1, sizeof(kName1))));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user