Skip to content

Commit a5d5d13

Browse files
Credential modification should check type, not just index. (#35073)
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.
1 parent a9027ca commit a5d5d13

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/app/clusters/door-lock-server/door-lock-server.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -2312,8 +2312,9 @@ DlStatus DoorLockServer::modifyCredentialForUser(chip::EndpointId endpointId, ch
23122312

23132313
for (size_t i = 0; i < user.credentials.size(); ++i)
23142314
{
2315-
// appclusters, 5.2.4.40: user should already be associated with given credentialIndex
2316-
if (user.credentials.data()[i].credentialIndex == credential.credentialIndex)
2315+
// appclusters, 5.2.4.40: user should already be associated with given credential
2316+
if (user.credentials[i].credentialType == credential.credentialType &&
2317+
user.credentials[i].credentialIndex == credential.credentialIndex)
23172318
{
23182319
chip::Platform::ScopedMemoryBuffer<CredentialStruct> newCredentials;
23192320
if (!newCredentials.Alloc(user.credentials.size()))
@@ -2357,7 +2358,7 @@ DlStatus DoorLockServer::modifyCredentialForUser(chip::EndpointId endpointId, ch
23572358
}
23582359
}
23592360

2360-
// appclusters, 5.2.4.40: if user is not associated with credential index we should return INVALID_COMMAND
2361+
// appclusters, 5.2.4.40: if user is not associated with the given credential we should return INVALID_COMMAND
23612362
ChipLogProgress(Zcl,
23622363
"[ModifyUserCredential] Unable to modify user credential: user is not associated with credential index "
23632364
"[endpointId=%d,userIndex=%d,credentialIndex=%d]",

0 commit comments

Comments
 (0)