Skip to content

Commit 7a020ae

Browse files
Fix reads on the group key management cluster to handle chunking correctly. (project-chip#36975)
We were not propagating out encoding status, so when we reached end of packet we would just silently return CHIP_NO_ERROR instead of indicating we had more data to encode. Fixes project-chip#36882
1 parent fd7d972 commit 7a020ae

File tree

2 files changed

+426
-4
lines changed

2 files changed

+426
-4
lines changed

src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp

+24-4
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ class GroupKeyManagementAttributeAccess : public AttributeAccessInterface
167167
VerifyOrReturnError(nullptr != provider, CHIP_ERROR_INTERNAL);
168168

169169
CHIP_ERROR err = aEncoder.EncodeList([provider](const auto & encoder) -> CHIP_ERROR {
170+
CHIP_ERROR encodeStatus = CHIP_NO_ERROR;
171+
170172
for (auto & fabric : Server::GetInstance().GetFabricTable())
171173
{
172174
auto fabric_index = fabric.GetFabricIndex();
@@ -181,11 +183,19 @@ class GroupKeyManagementAttributeAccess : public AttributeAccessInterface
181183
.groupKeySetID = mapping.keyset_id,
182184
.fabricIndex = fabric_index,
183185
};
184-
encoder.Encode(key);
186+
encodeStatus = encoder.Encode(key);
187+
if (encodeStatus != CHIP_NO_ERROR)
188+
{
189+
break;
190+
}
185191
}
186192
iter->Release();
193+
if (encodeStatus != CHIP_NO_ERROR)
194+
{
195+
break;
196+
}
187197
}
188-
return CHIP_NO_ERROR;
198+
return encodeStatus;
189199
});
190200
return err;
191201
}
@@ -255,6 +265,8 @@ class GroupKeyManagementAttributeAccess : public AttributeAccessInterface
255265
VerifyOrReturnError(nullptr != provider, CHIP_ERROR_INTERNAL);
256266

257267
CHIP_ERROR err = aEncoder.EncodeList([provider](const auto & encoder) -> CHIP_ERROR {
268+
CHIP_ERROR encodeStatus = CHIP_NO_ERROR;
269+
258270
for (auto & fabric : Server::GetInstance().GetFabricTable())
259271
{
260272
auto fabric_index = fabric.GetFabricIndex();
@@ -264,11 +276,19 @@ class GroupKeyManagementAttributeAccess : public AttributeAccessInterface
264276
GroupDataProvider::GroupInfo info;
265277
while (iter->Next(info))
266278
{
267-
encoder.Encode(GroupTableCodec(provider, fabric_index, info));
279+
encodeStatus = encoder.Encode(GroupTableCodec(provider, fabric_index, info));
280+
if (encodeStatus != CHIP_NO_ERROR)
281+
{
282+
break;
283+
}
268284
}
269285
iter->Release();
286+
if (encodeStatus != CHIP_NO_ERROR)
287+
{
288+
break;
289+
}
270290
}
271-
return CHIP_NO_ERROR;
291+
return encodeStatus;
272292
});
273293
return err;
274294
}

0 commit comments

Comments
 (0)