Skip to content

Commit d263b42

Browse files
Address PR Comments
1 parent 465f21f commit d263b42

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/app/util/attribute-storage.cpp

+8-9
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,9 @@ CHIP_ERROR emberAfSetDynamicEndpoint(uint16_t index, EndpointId id, const EmberA
293293
}
294294
}
295295

296-
for (uint8_t i = 0; ep && (i < ep->clusterCount); i++)
296+
const size_t bufferSize = Compatibility::Internal::gEmberAttributeIOBufferSpan.size();
297+
for (uint8_t i = 0; i < ep->clusterCount; i++)
297298
{
298-
if (!ep->cluster)
299-
{
300-
continue;
301-
}
302-
303299
const EmberAfCluster * cluster = &(ep->cluster[i]);
304300
if (!cluster->attributes)
305301
{
@@ -309,11 +305,14 @@ CHIP_ERROR emberAfSetDynamicEndpoint(uint16_t index, EndpointId id, const EmberA
309305
for (uint16_t j = 0; j < cluster->attributeCount; j++)
310306
{
311307
const EmberAfAttributeMetadata * attr = &(cluster->attributes[j]);
312-
if (emberAfAttributeSize(attr) > chip::app::Compatibility::Internal::gEmberAttributeIOBufferSpan.size())
308+
uint16_t attrSize = emberAfAttributeSize(attr);
309+
if (attrSize > bufferSize)
313310
{
314311
ChipLogError(DataManagement,
315-
"Attribute %u (id=" ChipLogFormatMEI ") of Cluster %u (id=" ChipLogFormatMEI ") too large", j,
316-
ChipLogValueMEI(attr->attributeId), i, ChipLogValueMEI(cluster->clusterId));
312+
"Attribute size %u exceeds max size %lu, (attrId=" ChipLogFormatMEI ", clusterId=" ChipLogFormatMEI
313+
")",
314+
attrSize, static_cast<unsigned long>(bufferSize), ChipLogValueMEI(attr->attributeId),
315+
ChipLogValueMEI(cluster->clusterId));
317316
return CHIP_ERROR_NO_MEMORY;
318317
}
319318
}

src/controller/tests/TestServerCommandDispatch.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ TEST_F(TestServerCommandDispatch, TestNoHandler)
215215
EXPECT_EQ(GetExchangeManager().GetNumActiveExchanges(), 0u);
216216
}
217217

218-
static const int kDescriptorAttributeArraySize = 254;
218+
// Use 8 so that we don't exceed the size of ATTRIBUTE_LARGEST defined by ZAP
219+
static const int kDescriptorAttributeArraySize = 8;
219220

220221
// Declare Descriptor cluster attributes
221222
DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(descriptorAttrs)

0 commit comments

Comments
 (0)