Skip to content

Commit 838480b

Browse files
bzbarsky-appleaustina-csa
authored andcommitted
Credential modification should check type, not just index. (project-chip#34841)
Credential indices are per-type, so we should be checking both when locating the credential to be modified. Fixes project-chip#34816
1 parent 870be69 commit 838480b

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
@@ -2340,8 +2340,9 @@ DlStatus DoorLockServer::modifyCredentialForUser(chip::EndpointId endpointId, ch
23402340

23412341
for (size_t i = 0; i < user.credentials.size(); ++i)
23422342
{
2343-
// appclusters, 5.2.4.40: user should already be associated with given credentialIndex
2344-
if (user.credentials.data()[i].credentialIndex == credential.credentialIndex)
2343+
// appclusters, 5.2.4.40: user should already be associated with given credential
2344+
if (user.credentials[i].credentialType == credential.credentialType &&
2345+
user.credentials[i].credentialIndex == credential.credentialIndex)
23452346
{
23462347
chip::Platform::ScopedMemoryBuffer<CredentialStruct> newCredentials;
23472348
if (!newCredentials.Alloc(user.credentials.size()))
@@ -2385,7 +2386,7 @@ DlStatus DoorLockServer::modifyCredentialForUser(chip::EndpointId endpointId, ch
23852386
}
23862387
}
23872388

2388-
// appclusters, 5.2.4.40: if user is not associated with credential index we should return INVALID_COMMAND
2389+
// appclusters, 5.2.4.40: if user is not associated with the given credential we should return INVALID_COMMAND
23892390
ChipLogProgress(Zcl,
23902391
"[ModifyUserCredential] Unable to modify user credential: user is not associated with credential index "
23912392
"[endpointId=%d,userIndex=%d,credentialIndex=%d]",

0 commit comments

Comments
 (0)