Skip to content
Open
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
18 changes: 16 additions & 2 deletions src/lib/SoftHSM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2048,9 +2048,23 @@ CK_RV SoftHSM::C_FindObjectsInit(CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pT
// Check if we are out of memory
if (findOp == NULL_PTR) return CKR_HOST_MEMORY;

std::set<OSObject*> tokenObjects;
std::set<OSObject*> sessionObjects;
token->getObjects(tokenObjects);
sessionObjectStore->getObjects(slot->getSlotID(), sessionObjects);

struct SessionObjReleaser {
std::set<OSObject*>& s;
~SessionObjReleaser()
{
for (auto* o : s)
o->release();
}
} sessionObjectGuard{sessionObjects};

std::set<OSObject*> allObjects;
token->getObjects(allObjects);
sessionObjectStore->getObjects(slot->getSlotID(),allObjects);
allObjects.insert(tokenObjects.begin(), tokenObjects.end());
allObjects.insert(sessionObjects.begin(), sessionObjects.end());

std::set<CK_OBJECT_HANDLE> handles;
std::set<OSObject*>::iterator it;
Expand Down
1 change: 1 addition & 0 deletions src/lib/handle_mgr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set(INCLUDE_DIRS ${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/../data_mgr
${PROJECT_SOURCE_DIR}/../object_store
${PROJECT_SOURCE_DIR}/../pkcs11
${PROJECT_SOURCE_DIR}/../session_mgr
${PROJECT_SOURCE_DIR}/../slot_mgr
)

Expand Down
9 changes: 6 additions & 3 deletions src/lib/handle_mgr/Handle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,20 @@

// Constructor
Handle::Handle(CK_HANDLE_KIND _kind, CK_SLOT_ID _slotID, CK_SESSION_HANDLE _hSession)
: kind(_kind), slotID(_slotID), hSession(_hSession), object(NULL_PTR), isPrivate(false)
: kind(_kind), slotID(_slotID), hSession(_hSession), object(nullptr), session(nullptr),
isPrivate(false)
{
}

Handle::Handle(CK_HANDLE_KIND _kind, CK_SLOT_ID _slotID)
: kind(_kind), slotID(_slotID), hSession(CK_INVALID_HANDLE), object(NULL_PTR), isPrivate(false)
: kind(_kind), slotID(_slotID), hSession(CK_INVALID_HANDLE), object(nullptr), session(nullptr),
isPrivate(false)
{
}

Handle::Handle()
: kind(CKH_INVALID), slotID(0), hSession(CK_INVALID_HANDLE), object(NULL_PTR), isPrivate(false)
: kind(CKH_INVALID), slotID(0), hSession(CK_INVALID_HANDLE), object(nullptr), session(nullptr),
isPrivate(false)
{

}
5 changes: 4 additions & 1 deletion src/lib/handle_mgr/Handle.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#define _SOFTHSM_V2_HANDLE_H

#include "cryptoki.h"
#include "OSObject.h"
#include "Session.h"

enum {
CKH_INVALID,
Expand All @@ -54,7 +56,8 @@ class Handle
CK_SLOT_ID slotID;
CK_SESSION_HANDLE hSession;

CK_VOID_PTR object;
OSObject *object;
Session *session;
bool isPrivate;
};

Expand Down
Loading
Loading