Skip to content

Commit c8380ca

Browse files
Address PR Comments
1 parent 1010971 commit c8380ca

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/app/util/attribute-storage.cpp

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

295-
for (uint8_t i = 0; ep && (i < ep->clusterCount); i++)
295+
for (uint8_t i = 0; i < ep->clusterCount; i++)
296296
{
297-
if (!ep->cluster)
298-
{
299-
continue;
300-
}
301-
302297
const EmberAfCluster * cluster = &(ep->cluster[i]);
303298
if (!cluster->attributes)
304299
{
@@ -308,11 +303,14 @@ CHIP_ERROR emberAfSetDynamicEndpoint(uint16_t index, EndpointId id, const EmberA
308303
for (uint16_t j = 0; j < cluster->attributeCount; j++)
309304
{
310305
const EmberAfAttributeMetadata * attr = &(cluster->attributes[j]);
311-
if (emberAfAttributeSize(attr) > chip::app::Compatibility::Internal::gEmberAttributeIOBufferSpan.size())
306+
uint16_t attrSize = emberAfAttributeSize(attr);
307+
size_t bufferSize = Compatibility::Internal::gEmberAttributeIOBufferSpan.size();
308+
if (attrSize > bufferSize)
312309
{
313310
ChipLogError(DataManagement,
314-
"Attribute %u (id=" ChipLogFormatMEI ") of Cluster %u (id=" ChipLogFormatMEI ") too large", j,
315-
ChipLogValueMEI(attr->attributeId), i, ChipLogValueMEI(cluster->clusterId));
311+
"Attribute size %u exceeds max size %zu, (attrId="ChipLogFormatMEI ", clusterId=" ChipLogFormatMEI
312+
")",
313+
attrSize, bufferSize, ChipLogValueMEI(attr->attributeId), ChipLogValueMEI(cluster->clusterId));
316314
return CHIP_ERROR_NO_MEMORY;
317315
}
318316
}

0 commit comments

Comments
 (0)