Skip to content

Commit

Permalink
Revert "[nrf fromtree] Make sure we don't trash our userinfo after we…
Browse files Browse the repository at this point in the history
… get it and before we send it. (project-chip#26373) (project-chip#26421)"

This reverts commit 9b427d6.
  • Loading branch information
kkasperczyk-no committed Nov 9, 2023
1 parent da22070 commit 2f3d58c
Showing 1 changed file with 7 additions and 14 deletions.
21 changes: 7 additions & 14 deletions src/app/clusters/door-lock-server/door-lock-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,20 +453,6 @@ void DoorLockServer::getUserCommandHandler(chip::app::CommandHandler * commandOb
return;
}

Commands::GetUserResponse::Type response;

// appclusters, 5.2.4.36.1: We need to add next occupied user after userIndex if any.
//
// We want to do this before we call emberAfPluginDoorLockGetUser, because this will
// make its own emberAfPluginDoorLockGetUser calls, and a
// EmberAfPluginDoorLockUserInfo might be pointing into some application-static
// buffers (for its credentials and whatnot).
uint16_t nextAvailableUserIndex = 0;
if (findOccupiedUserSlot(commandPath.mEndpointId, static_cast<uint16_t>(userIndex + 1), nextAvailableUserIndex))
{
response.nextUserIndex.SetNonNull(nextAvailableUserIndex);
}

EmberAfPluginDoorLockUserInfo user;
if (!emberAfPluginDoorLockGetUser(commandPath.mEndpointId, userIndex, user))
{
Expand All @@ -475,6 +461,7 @@ void DoorLockServer::getUserCommandHandler(chip::app::CommandHandler * commandOb
return;
}

Commands::GetUserResponse::Type response;
response.userIndex = userIndex;

// appclusters, 5.2.4.36: we should not set user-specific fields to non-null if the user status is set to Available
Expand Down Expand Up @@ -511,6 +498,12 @@ void DoorLockServer::getUserCommandHandler(chip::app::CommandHandler * commandOb
emberAfDoorLockClusterPrintln("[GetUser] User not found [userIndex=%d]", userIndex);
}

// appclusters, 5.2.4.36.1: We need to add next occupied user after userIndex if any.
uint16_t nextAvailableUserIndex = 0;
if (findOccupiedUserSlot(commandPath.mEndpointId, static_cast<uint16_t>(userIndex + 1), nextAvailableUserIndex))
{
response.nextUserIndex.SetNonNull(nextAvailableUserIndex);
}
commandObj->AddResponse(commandPath, response);
}

Expand Down

0 comments on commit 2f3d58c

Please sign in to comment.