Skip to content

Commit

Permalink
Fix RESOURCE_EXHAUSTED in KeySetWrite (project-chip#28456)
Browse files Browse the repository at this point in the history
* Fix RESOURCE_EXHAUSTED in KeySetWrite

* Restyled by prettier-yaml

---------

Co-authored-by: [email protected] <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Andrei Litvin <[email protected]>
  • Loading branch information
4 people authored Aug 3, 2023
1 parent b3d3685 commit 27c3ff4
Show file tree
Hide file tree
Showing 4 changed files with 332 additions and 219 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,12 @@ bool emberAfGroupKeyManagementClusterKeySetWriteCallback(

// Set KeySet
err = provider->SetKeySet(fabric->GetFabricIndex(), compressed_fabric_id, keyset);
if (CHIP_ERROR_INVALID_LIST_LENGTH == err)
{
commandObj->AddStatusAndLogIfFailure(commandPath, Status::ResourceExhausted, "Not enough space left to add a new KeySet");
return true;
}

if (CHIP_NO_ERROR == err)
{
ChipLogDetail(Zcl, "GroupKeyManagementCluster: KeySetWrite OK");
Expand Down
19 changes: 19 additions & 0 deletions src/app/tests/suites/TestGroupKeyManagementCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,25 @@ tests:
# Note: There's always an IPK keyset with index 0
contains: [0x01a1, 0x01a2, 0]

- label: "Write one keyset too many when already full"
command: "KeySetWrite"
arguments:
values:
- name: "GroupKeySet"
value:
{
GroupKeySetID: 0x0222,
GroupKeySecurityPolicy: 0,
EpochKey0: "\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf",
EpochStartTime0: 3110000,
EpochKey1: "\xe1\xe1\xe2\xe3\xe4\xe5\xe6\xe7\xe8\xe9\xea\xeb\xec\xed\xee\xef",
EpochStartTime1: 3110001,
EpochKey2: "\xf1\xf1\xf2\xf3\xf4\xf5\xf6\xf7\xf8\xf9\xfa\xfb\xfc\xfd\xfe\xff",
EpochStartTime2: 3110002,
}
response:
error: RESOURCE_EXHAUSTED

- label: "Write Group Keys (invalid)"
command: "writeAttribute"
attribute: "GroupKeyMap"
Expand Down
Loading

0 comments on commit 27c3ff4

Please sign in to comment.