Skip to content

Commit

Permalink
Address PR Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
witowsg-amazon committed Oct 10, 2024
1 parent 1010971 commit 1216792
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/app/util/attribute-storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -292,13 +292,8 @@ CHIP_ERROR emberAfSetDynamicEndpoint(uint16_t index, EndpointId id, const EmberA
}
}

for (uint8_t i = 0; ep && (i < ep->clusterCount); i++)
for (uint8_t i = 0; i < ep->clusterCount; i++)
{
if (!ep->cluster)
{
continue;
}

const EmberAfCluster * cluster = &(ep->cluster[i]);
if (!cluster->attributes)
{
Expand All @@ -308,11 +303,13 @@ CHIP_ERROR emberAfSetDynamicEndpoint(uint16_t index, EndpointId id, const EmberA
for (uint16_t j = 0; j < cluster->attributeCount; j++)
{
const EmberAfAttributeMetadata * attr = &(cluster->attributes[j]);
if (emberAfAttributeSize(attr) > chip::app::Compatibility::Internal::gEmberAttributeIOBufferSpan.size())
uint16_t attrSize = emberAfAttributeSize(attr);
size_t bufferSize = Compatibility::Internal::gEmberAttributeIOBufferSpan.size();
if (attrSize > bufferSize)
{
ChipLogError(DataManagement,
"Attribute %u (id=" ChipLogFormatMEI ") of Cluster %u (id=" ChipLogFormatMEI ") too large", j,
ChipLogValueMEI(attr->attributeId), i, ChipLogValueMEI(cluster->clusterId));
"Attribute size %u exceeds max size %zu, (attrId="ChipLogFormatMEI ", clusterId=" ChipLogFormatMEI ")",
attrSize, bufferSize, ChipLogValueMEI(attr->attributeId), ChipLogValueMEI(cluster->clusterId));
return CHIP_ERROR_NO_MEMORY;
}
}
Expand Down

0 comments on commit 1216792

Please sign in to comment.