From 3285588e85bd097398f20eb1ed308713f120fcd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Kr=C3=B3lik?= <66667989+Damian-Nordic@users.noreply.github.com> Date: Thu, 3 Mar 2022 18:25:53 +0100 Subject: [PATCH] [groups] Fix storing group data counter (#15795) Depending on the KVS implementation, the size variable passed to the SyncSetKeyValue() might have been modified by previous SyncGetKeyValue() calls. --- src/transport/GroupPeerMessageCounter.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/transport/GroupPeerMessageCounter.cpp b/src/transport/GroupPeerMessageCounter.cpp index 91dfc2b2a38aa3..5723af6644acba 100644 --- a/src/transport/GroupPeerMessageCounter.cpp +++ b/src/transport/GroupPeerMessageCounter.cpp @@ -275,6 +275,7 @@ CHIP_ERROR GroupOutgoingCounters::Init(chip::PersistentStorageDelegate * storage } temp = mGroupControlCounter + GROUP_MSG_COUNTER_MIN_INCREMENT; + size = static_cast(sizeof(temp)); ReturnErrorOnFailure(mStorage->SyncSetKeyValue(key.GroupControlCounter(), &temp, size)); temp = mGroupDataCounter + GROUP_MSG_COUNTER_MIN_INCREMENT;