From 68c7bedc65037e4f6c8acb8f6802ddb21351612f Mon Sep 17 00:00:00 2001 From: lpbeliveau-silabs Date: Fri, 24 Mar 2023 15:08:55 -0400 Subject: [PATCH] Added ArraySize() for checks in default scne handlers --- src/app/clusters/scenes/SceneTableImpl.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/app/clusters/scenes/SceneTableImpl.h b/src/app/clusters/scenes/SceneTableImpl.h index 11d83b14a5239d..c136d4f630c124 100644 --- a/src/app/clusters/scenes/SceneTableImpl.h +++ b/src/app/clusters/scenes/SceneTableImpl.h @@ -59,8 +59,7 @@ class DefaultSceneHandlerImpl : public scenes::SceneHandler // Verify size of list ReturnErrorOnFailure(extensionFieldSet.attributeValueList.ComputeSize(&pairTotal)); - VerifyOrReturnError(pairTotal <= Span(mAVPairs).size(), - CHIP_ERROR_BUFFER_TOO_SMALL); + VerifyOrReturnError(pairTotal <= ArraySize(mAVPairs), CHIP_ERROR_BUFFER_TOO_SMALL); auto pair_iterator = extensionFieldSet.attributeValueList.begin(); while (pair_iterator.Next()) @@ -71,7 +70,7 @@ class DefaultSceneHandlerImpl : public scenes::SceneHandler uint8_t valueBytesCount = 0; ReturnErrorOnFailure(aVPair.attributeValue.ComputeSize(&valueBytesTotal)); - VerifyOrReturnError(valueBytesTotal <= Span(mValueBuffer[0]).size(), CHIP_ERROR_BUFFER_TOO_SMALL); + VerifyOrReturnError(valueBytesTotal <= ArraySize(mValueBuffer[0]), CHIP_ERROR_BUFFER_TOO_SMALL); auto value_iterator = aVPair.attributeValue.begin(); while (value_iterator.Next()) @@ -128,8 +127,7 @@ class DefaultSceneHandlerImpl : public scenes::SceneHandler // Verify size of list ReturnErrorOnFailure(attributeValueList.ComputeSize(&pairTotal)); - VerifyOrReturnError(pairTotal <= Span(mAVPairs).size(), - CHIP_ERROR_BUFFER_TOO_SMALL); + VerifyOrReturnError(pairTotal <= ArraySize(mAVPairs), CHIP_ERROR_BUFFER_TOO_SMALL); auto pair_iterator = attributeValueList.begin(); while (pair_iterator.Next()) @@ -141,7 +139,7 @@ class DefaultSceneHandlerImpl : public scenes::SceneHandler // Verify size of attribute value ReturnErrorOnFailure(decodePair.attributeValue.ComputeSize(&valueBytesTotal)); - VerifyOrReturnError(valueBytesTotal <= Span(mValueBuffer[0]).size(), CHIP_ERROR_BUFFER_TOO_SMALL); + VerifyOrReturnError(valueBytesTotal <= ArraySize(mValueBuffer[0]), CHIP_ERROR_BUFFER_TOO_SMALL); auto value_iterator = decodePair.attributeValue.begin(); while (value_iterator.Next())