Skip to content

Commit

Permalink
Make length validation of group names follow the spec. (#29604)
Browse files Browse the repository at this point in the history
Fixes #29576
  • Loading branch information
bzbarsky-apple authored Oct 6, 2023
1 parent a815235 commit c73199d
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 73 deletions.
1 change: 1 addition & 0 deletions src/app/clusters/groups-server/groups-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ static bool KeyExists(FabricIndex fabricIndex, GroupId groupId)
static Status GroupAdd(FabricIndex fabricIndex, EndpointId endpointId, GroupId groupId, const CharSpan & groupName)
{
VerifyOrReturnError(IsValidGroupId(groupId), Status::ConstraintError);
VerifyOrReturnError(groupName.size() <= GroupDataProvider::GroupInfo::kGroupNameMax, Status::ConstraintError);

GroupDataProvider * provider = GetGroupDataProvider();
VerifyOrReturnError(nullptr != provider, Status::NotFound);
Expand Down
25 changes: 20 additions & 5 deletions src/app/tests/suites/TestGroupsCluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ tests:
response:
values:
- name: "Status"
value: 0x7e
value: 0x7e # UNSUPPORTED_ACCESS
- name: "GroupID"
value: 0x0101

Expand Down Expand Up @@ -100,14 +100,29 @@ tests:
{ FabricIndex: 1, GroupId: 0x0102, GroupKeySetID: 0x01a1 },
]

- label: "Add First Group (name too long)"
command: "AddGroup"
arguments:
values:
- name: "GroupID"
value: 0x0101
- name: "GroupName"
value: "12345678901234567"
response:
values:
- name: "Status"
value: 0x87 # CONSTRAINT_ERROR
- name: "GroupID"
value: 0x0101

- label: "Add First Group (new)"
command: "AddGroup"
arguments:
values:
- name: "GroupID"
value: 0x0101
- name: "GroupName"
value: "Group #1"
value: "Group #101234567" # Maximal-length name, to check that this works
response:
values:
- name: "Status"
Expand All @@ -128,7 +143,7 @@ tests:
- name: "GroupID"
value: 0x0101
- name: "GroupName"
value: "Group #1"
value: "Group #101234567"

- label: "View Second Group (not found)"
command: "ViewGroup"
Expand Down Expand Up @@ -229,7 +244,7 @@ tests:
- name: "GroupID"
value: 0x0101
- name: "GroupName"
value: "Group #1"
value: "Group #101234567"

- label: "View Second Group (existing)"
command: "ViewGroup"
Expand Down Expand Up @@ -328,7 +343,7 @@ tests:
- name: "GroupID"
value: 0x0101
- name: "GroupName"
value: "Group #1"
value: "Group #101234567"

- label: "View Second Group (removed)"
command: "ViewGroup"
Expand Down
Loading

0 comments on commit c73199d

Please sign in to comment.