Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRLK] Bugfix: return INVALID_COMMAND when attempting to add/modify #34120

Merged
merged 3 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/app/clusters/door-lock-server/door-lock-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,19 @@ void DoorLockServer::setCredentialCommandHandler(
return;
}

// return INVALID_COMMAND if the accessing fabric index doesn’t match the
// CreatorFabricIndex of the credential being modified
if (existingCredential.createdBy != fabricIdx)
{
ChipLogProgress(Zcl,
"[createCredential] Unable to modify credential. Fabric index differs from creator fabric "
"[endpointId=%d,credentialIndex=%d,creatorIdx=%d,modifierIdx=%d]",
commandPath.mEndpointId, credentialIndex, existingCredential.createdBy, fabricIdx);

sendSetCredentialResponse(commandObj, commandPath, DlStatus::kInvalidField, 0, nextAvailableCredentialSlot);
return;
}

// if userIndex is NULL then we're changing the programming user PIN
if (userIndex.IsNull())
{
Expand Down Expand Up @@ -2192,6 +2205,17 @@ DlStatus DoorLockServer::createNewCredentialAndAddItToUser(chip::EndpointId endp
return DlStatus::kInvalidField;
}

// return INVALID_COMMAND if the accessing fabric index doesn’t match the
// CreatorFabricIndex in the user record pointed to by UserIndex
if (user.createdBy != modifierFabricIdx)
{
ChipLogProgress(Zcl,
"[createCredential] Unable to create credential for user created by different fabric "
"[endpointId=%d,userIndex=%d,creatorIdx=%d,fabricIdx=%d]",
endpointId, userIndex, user.createdBy, modifierFabricIdx);
return DlStatus::kInvalidField;
}

// Add new credential to the user
auto status = addCredentialToUser(endpointId, modifierFabricIdx, userIndex, credential);
if (DlStatus::kSuccess != status)
Expand Down Expand Up @@ -2312,6 +2336,17 @@ DlStatus DoorLockServer::modifyCredentialForUser(chip::EndpointId endpointId, ch
return DlStatus::kFailure;
}

// return INVALID_COMMAND if the accessing fabric index doesn’t match the
// CreatorFabricIndex in the user record pointed to by UserIndex
if (user.createdBy != modifierFabricIdx)
{
ChipLogProgress(Zcl,
"[createCredential] Unable to modify credential for user created by different fabric "
"[endpointId=%d,userIndex=%d,creatorIdx=%d,fabricIdx=%d]",
endpointId, userIndex, user.createdBy, modifierFabricIdx);
return DlStatus::kInvalidField;
}

for (size_t i = 0; i < user.credentials.size(); ++i)
{
// appclusters, 5.2.4.40: user should already be associated with given credentialIndex
Expand Down
Loading
Loading