@@ -293,13 +293,9 @@ CHIP_ERROR emberAfSetDynamicEndpoint(uint16_t index, EndpointId id, const EmberA
293
293
}
294
294
}
295
295
296
- for (uint8_t i = 0 ; ep && (i < ep->clusterCount ); i++)
296
+ size_t bufferSize = Compatibility::Internal::gEmberAttributeIOBufferSpan .size ();
297
+ for (uint8_t i = 0 ; i < ep->clusterCount ; i++)
297
298
{
298
- if (!ep->cluster )
299
- {
300
- continue ;
301
- }
302
-
303
299
const EmberAfCluster * cluster = &(ep->cluster [i]);
304
300
if (!cluster->attributes )
305
301
{
@@ -309,11 +305,13 @@ CHIP_ERROR emberAfSetDynamicEndpoint(uint16_t index, EndpointId id, const EmberA
309
305
for (uint16_t j = 0 ; j < cluster->attributeCount ; j++)
310
306
{
311
307
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)
313
310
{
314
- ChipLogError (DataManagement,
315
- " Attribute %u (id=" ChipLogFormatMEI " ) of Cluster %u (id=" ChipLogFormatMEI " ) too large" , j,
316
- ChipLogValueMEI (attr->attributeId ), i, ChipLogValueMEI (cluster->clusterId ));
311
+ ChipLogError (
312
+ DataManagement,
313
+ " Attribute size %u exceeds max size %lu, (attrId=" ChipLogFormatMEI " , clusterId=" ChipLogFormatMEI " )" ,
314
+ attrSize, (unsigned long ) bufferSize, ChipLogValueMEI (attr->attributeId ), ChipLogValueMEI (cluster->clusterId ));
317
315
return CHIP_ERROR_NO_MEMORY;
318
316
}
319
317
}
0 commit comments