Skip to content

Commit

Permalink
[Thread] fix assertions in operational dataset (#22858)
Browse files Browse the repository at this point in the history
The assertions in `SetExtendedPanId` and `SetMasterKey` would fail if the dataset is exactly 254 bytes after sets it.
  • Loading branch information
jinran-google authored and pull[bot] committed Dec 15, 2023
1 parent 0d117b6 commit 2657426
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/support/ThreadOperationalDataset.cpp
Original file line number Diff line number Diff line change
@@ -318,7 +318,7 @@ CHIP_ERROR OperationalDataset::SetExtendedPanId(const uint8_t (&aExtendedPanId)[

tlv->SetValue(aExtendedPanId, sizeof(aExtendedPanId));

assert(mLength + tlv->GetSize() < sizeof(mData));
assert(mLength + tlv->GetSize() <= sizeof(mData));

mLength = static_cast<uint8_t>(mLength + tlv->GetSize());

@@ -349,7 +349,7 @@ CHIP_ERROR OperationalDataset::SetMasterKey(const uint8_t (&aMasterKey)[kSizeMas

tlv->SetValue(aMasterKey, sizeof(aMasterKey));

assert(mLength + tlv->GetSize() < sizeof(mData));
assert(mLength + tlv->GetSize() <= sizeof(mData));

mLength = static_cast<uint8_t>(mLength + tlv->GetSize());

0 comments on commit 2657426

Please sign in to comment.