From 3482476d399bee45e8c967cae0846f3e794a5f48 Mon Sep 17 00:00:00 2001 From: jinran-google Date: Wed, 28 Sep 2022 22:06:25 +0800 Subject: [PATCH] [Thread] fix assertions in operational dataset (#22858) The assertions in `SetExtendedPanId` and `SetMasterKey` would fail if the dataset is exactly 254 bytes after sets it. --- src/lib/support/ThreadOperationalDataset.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/support/ThreadOperationalDataset.cpp b/src/lib/support/ThreadOperationalDataset.cpp index bb3837df3555bb..cbce0de667ac2a 100644 --- a/src/lib/support/ThreadOperationalDataset.cpp +++ b/src/lib/support/ThreadOperationalDataset.cpp @@ -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(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(mLength + tlv->GetSize());