Skip to content

Commit

Permalink
Credential modification should check type, not just index. (#35073)
Browse files Browse the repository at this point in the history
Credential indices are per-type, so we should be checking both when locating the
credential to be modified.

This is a backport of #34841 to the 1.3 branch.
  • Loading branch information
bzbarsky-apple authored Aug 30, 2024
1 parent a9027ca commit a5d5d13
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/app/clusters/door-lock-server/door-lock-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2312,8 +2312,9 @@ DlStatus DoorLockServer::modifyCredentialForUser(chip::EndpointId endpointId, ch

for (size_t i = 0; i < user.credentials.size(); ++i)
{
// appclusters, 5.2.4.40: user should already be associated with given credentialIndex
if (user.credentials.data()[i].credentialIndex == credential.credentialIndex)
// appclusters, 5.2.4.40: user should already be associated with given credential
if (user.credentials[i].credentialType == credential.credentialType &&
user.credentials[i].credentialIndex == credential.credentialIndex)
{
chip::Platform::ScopedMemoryBuffer<CredentialStruct> newCredentials;
if (!newCredentials.Alloc(user.credentials.size()))
Expand Down Expand Up @@ -2357,7 +2358,7 @@ DlStatus DoorLockServer::modifyCredentialForUser(chip::EndpointId endpointId, ch
}
}

// appclusters, 5.2.4.40: if user is not associated with credential index we should return INVALID_COMMAND
// appclusters, 5.2.4.40: if user is not associated with the given credential we should return INVALID_COMMAND
ChipLogProgress(Zcl,
"[ModifyUserCredential] Unable to modify user credential: user is not associated with credential index "
"[endpointId=%d,userIndex=%d,credentialIndex=%d]",
Expand Down

0 comments on commit a5d5d13

Please sign in to comment.