Skip to content

Commit

Permalink
Fix reads on the group key management cluster to handle chunking corr…
Browse files Browse the repository at this point in the history
…ectly. (project-chip#36975) (project-chip#37021)

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
  • Loading branch information
bzbarsky-apple authored Jan 10, 2025
1 parent fd7d972 commit fad424e
Show file tree
Hide file tree
Showing 2 changed files with 426 additions and 4 deletions.
28 changes: 24 additions & 4 deletions src/app/clusters/group-key-mgmt-server/group-key-mgmt-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ class GroupKeyManagementAttributeAccess : public AttributeAccessInterface
VerifyOrReturnError(nullptr != provider, CHIP_ERROR_INTERNAL);

CHIP_ERROR err = aEncoder.EncodeList([provider](const auto & encoder) -> CHIP_ERROR {
CHIP_ERROR encodeStatus = CHIP_NO_ERROR;

for (auto & fabric : Server::GetInstance().GetFabricTable())
{
auto fabric_index = fabric.GetFabricIndex();
Expand All @@ -181,11 +183,19 @@ class GroupKeyManagementAttributeAccess : public AttributeAccessInterface
.groupKeySetID = mapping.keyset_id,
.fabricIndex = fabric_index,
};
encoder.Encode(key);
encodeStatus = encoder.Encode(key);
if (encodeStatus != CHIP_NO_ERROR)
{
break;
}
}
iter->Release();
if (encodeStatus != CHIP_NO_ERROR)
{
break;
}
}
return CHIP_NO_ERROR;
return encodeStatus;
});
return err;
}
Expand Down Expand Up @@ -255,6 +265,8 @@ class GroupKeyManagementAttributeAccess : public AttributeAccessInterface
VerifyOrReturnError(nullptr != provider, CHIP_ERROR_INTERNAL);

CHIP_ERROR err = aEncoder.EncodeList([provider](const auto & encoder) -> CHIP_ERROR {
CHIP_ERROR encodeStatus = CHIP_NO_ERROR;

for (auto & fabric : Server::GetInstance().GetFabricTable())
{
auto fabric_index = fabric.GetFabricIndex();
Expand All @@ -264,11 +276,19 @@ class GroupKeyManagementAttributeAccess : public AttributeAccessInterface
GroupDataProvider::GroupInfo info;
while (iter->Next(info))
{
encoder.Encode(GroupTableCodec(provider, fabric_index, info));
encodeStatus = encoder.Encode(GroupTableCodec(provider, fabric_index, info));
if (encodeStatus != CHIP_NO_ERROR)
{
break;
}
}
iter->Release();
if (encodeStatus != CHIP_NO_ERROR)
{
break;
}
}
return CHIP_NO_ERROR;
return encodeStatus;
});
return err;
}
Expand Down
Loading

0 comments on commit fad424e

Please sign in to comment.