From d1d7bbe13b2aaf727fad9f995d2416284898ef84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Michalak-Szmaci=C5=84ski?= Date: Thu, 3 Aug 2023 07:30:54 +0200 Subject: [PATCH] Fix uninitialised values in KeySet and AttributePathExpandIterator (#28356) * Fix uninitialised value in KeySet * Fix uninitilised mGlobalAttributeEndIndex * Restyled by clang-format * Review proposed change initilize mGlobalAttributeEndIndex * Change initialize values in KeySet to initilize only start_time in EpochKey * Restyled by clang-format * Review proposed change initilize IPK keyset start_time --------- Co-authored-by: Restyled.io --- src/app/AttributePathExpandIterator.cpp | 5 +++++ .../operational-credentials-server.cpp | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app/AttributePathExpandIterator.cpp b/src/app/AttributePathExpandIterator.cpp index 6c45055c3933b0..5c1bb50c179f47 100644 --- a/src/app/AttributePathExpandIterator.cpp +++ b/src/app/AttributePathExpandIterator.cpp @@ -141,6 +141,11 @@ void AttributePathExpandIterator::PrepareAttributeIndexRange(const AttributePath } mGlobalAttributeEndIndex = static_cast(mGlobalAttributeIndex + 1); } + else + { + mGlobalAttributeIndex = UINT8_MAX; + mGlobalAttributeEndIndex = 0; + } } } diff --git a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp index 5a6c645a510670..4340f683b0d666 100644 --- a/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp +++ b/src/app/clusters/operational-credentials-server/operational-credentials-server.cpp @@ -654,9 +654,10 @@ bool emberAfOperationalCredentialsClusterAddNOCCallback(app::CommandHandler * co // Set the Identity Protection Key (IPK) // The IPK SHALL be the operational group key under GroupKeySetID of 0 - keyset.keyset_id = Credentials::GroupDataProvider::kIdentityProtectionKeySetId; - keyset.policy = GroupKeyManagement::GroupKeySecurityPolicyEnum::kTrustFirst; - keyset.num_keys_used = 1; + keyset.keyset_id = Credentials::GroupDataProvider::kIdentityProtectionKeySetId; + keyset.policy = GroupKeyManagement::GroupKeySecurityPolicyEnum::kTrustFirst; + keyset.num_keys_used = 1; + keyset.epoch_keys[0].start_time = 0; memcpy(keyset.epoch_keys[0].key, ipkValue.data(), Crypto::CHIP_CRYPTO_SYMMETRIC_KEY_LENGTH_BYTES); err = newFabricInfo->GetCompressedFabricIdBytes(compressed_fabric_id);