From 12167927c6538173e22be08b2d716a084ecf41c0 Mon Sep 17 00:00:00 2001 From: Garrett Witowski Date: Thu, 10 Oct 2024 14:45:59 -0700 Subject: [PATCH] Address PR Comments --- src/app/util/attribute-storage.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/app/util/attribute-storage.cpp b/src/app/util/attribute-storage.cpp index 3e9e7169046bab..79a8d80e8585af 100644 --- a/src/app/util/attribute-storage.cpp +++ b/src/app/util/attribute-storage.cpp @@ -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) { @@ -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; } }