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

Fix DoorLockServer::getNodeId somewhat. #26770

Merged
Merged
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
19 changes: 15 additions & 4 deletions src/app/clusters/door-lock-server/door-lock-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1367,18 +1367,29 @@ chip::FabricIndex DoorLockServer::getFabricIndex(const chip::app::CommandHandler

chip::NodeId DoorLockServer::getNodeId(const chip::app::CommandHandler * commandObj)
{
// TODO: Why are we doing all these checks? At all the callsites we have
// just received a command, so we better have a handler, exchange, session,
// etc. The only thing we should be checking is that it's a CASE session.
if (nullptr == commandObj || nullptr == commandObj->GetExchangeContext())
{
ChipLogError(Zcl, "Cannot access ExchangeContext of Command Object for Node ID");
return kUndefinedNodeId;
}

auto secureSession = commandObj->GetExchangeContext()->GetSessionHandle()->AsSecureSession();
if (nullptr == secureSession)
if (!commandObj->GetExchangeContext()->HasSessionHandle())
{
ChipLogError(Zcl, "Cannot access Secure session handle of Command Object for Node ID");
ChipLogError(Zcl, "Cannot access session of Command Object for Node ID");
return kUndefinedNodeId;
}

auto descriptor = commandObj->GetExchangeContext()->GetSessionHandle()->GetSubjectDescriptor();
if (descriptor.authMode != Access::AuthMode::kCase)
{
ChipLogError(Zcl, "Cannot get Node ID from non-CASE session of Command Object");
return kUndefinedNodeId;
}
return secureSession->GetPeerNodeId();

return descriptor.subject;
}

bool DoorLockServer::userIndexValid(chip::EndpointId endpointId, uint16_t userIndex)
Expand Down