Skip to content

Commit 232543f

Browse files
Credential modification should check type, not just index. (#35074)
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.2 branch.
1 parent e9980ee commit 232543f

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

22512251
for (size_t i = 0; i < user.credentials.size(); ++i)
22522252
{
2253-
// appclusters, 5.2.4.40: user should already be associated with given credentialIndex
2254-
if (user.credentials.data()[i].credentialIndex == credential.credentialIndex)
2253+
// appclusters, 5.2.4.40: user should already be associated with given credential
2254+
if (user.credentials[i].credentialType == credential.credentialType &&
2255+
user.credentials[i].credentialIndex == credential.credentialIndex)
22552256
{
22562257
chip::Platform::ScopedMemoryBuffer<CredentialStruct> newCredentials;
22572258
if (!newCredentials.Alloc(user.credentials.size()))
@@ -2295,7 +2296,7 @@ DlStatus DoorLockServer::modifyCredentialForUser(chip::EndpointId endpointId, ch
22952296
}
22962297
}
22972298

2298-
// appclusters, 5.2.4.40: if user is not associated with credential index we should return INVALID_COMMAND
2299+
// appclusters, 5.2.4.40: if user is not associated with the given credential we should return INVALID_COMMAND
22992300
ChipLogProgress(Zcl,
23002301
"[ModifyUserCredential] Unable to modify user credential: user is not associated with credential index "
23012302
"[endpointId=%d,userIndex=%d,credentialIndex=%d]",

0 commit comments

Comments
 (0)