- in case of an invalid session/object handle, return OBJECT_HANDLE_INVALID
or SESSION_HANDLE_INVALID instead of FUNCTION_DAILED git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@721 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
6f4587f612
commit
c3b479fc82
|
@ -85,8 +85,9 @@ void dump_template(const char *info, CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCoun
|
|||
}
|
||||
|
||||
/* Pool */
|
||||
CK_RV pool_initialize(struct sc_pkcs11_pool *pool)
|
||||
CK_RV pool_initialize(struct sc_pkcs11_pool *pool, int type)
|
||||
{
|
||||
pool->type = type;
|
||||
pool->next_free_handle = 1;
|
||||
pool->num_items = 0;
|
||||
pool->head = pool->tail = NULL;
|
||||
|
@ -132,7 +133,8 @@ CK_RV pool_find(struct sc_pkcs11_pool *pool, CK_ULONG handle, void **item_ptr)
|
|||
}
|
||||
}
|
||||
|
||||
return CKR_FUNCTION_FAILED;
|
||||
return (pool->type == POOL_TYPE_OBJECT)? CKR_OBJECT_HANDLE_INVALID
|
||||
: CKR_SESSION_HANDLE_INVALID;
|
||||
}
|
||||
|
||||
CK_RV pool_find_and_delete(struct sc_pkcs11_pool *pool, CK_ULONG handle, void **item_ptr)
|
||||
|
@ -156,7 +158,8 @@ CK_RV pool_find_and_delete(struct sc_pkcs11_pool *pool, CK_ULONG handle, void **
|
|||
}
|
||||
}
|
||||
|
||||
return CKR_FUNCTION_FAILED;
|
||||
return (pool->type == POOL_TYPE_OBJECT)? CKR_OBJECT_HANDLE_INVALID
|
||||
: CKR_SESSION_HANDLE_INVALID;
|
||||
}
|
||||
|
||||
/* Session manipulation */
|
||||
|
|
|
@ -41,7 +41,7 @@ CK_RV C_Initialize(CK_VOID_PTR pReserved)
|
|||
if (rc != 0)
|
||||
return CKR_DEVICE_ERROR;
|
||||
|
||||
pool_initialize(&session_pool);
|
||||
pool_initialize(&session_pool, POOL_TYPE_SESSION);
|
||||
for (i=0; i<SC_PKCS11_MAX_VIRTUAL_SLOTS; i++)
|
||||
slot_initialize(i, &virtual_slots[i]);
|
||||
for (i=0; i<SC_PKCS11_MAX_READERS; i++)
|
||||
|
|
|
@ -65,7 +65,13 @@ struct sc_pkcs11_pool_item {
|
|||
struct sc_pkcs11_pool_item *prev;
|
||||
};
|
||||
|
||||
enum {
|
||||
POOL_TYPE_SESSION,
|
||||
POOL_TYPE_OBJECT
|
||||
};
|
||||
|
||||
struct sc_pkcs11_pool {
|
||||
int type;
|
||||
int next_free_handle;
|
||||
int num_items;
|
||||
struct sc_pkcs11_pool_item *head;
|
||||
|
@ -238,7 +244,7 @@ CK_RV slot_token_removed(int id);
|
|||
CK_RV slot_allocate(struct sc_pkcs11_slot **, struct sc_pkcs11_card *);
|
||||
|
||||
/* Pool */
|
||||
CK_RV pool_initialize(struct sc_pkcs11_pool *);
|
||||
CK_RV pool_initialize(struct sc_pkcs11_pool *, int);
|
||||
CK_RV pool_insert(struct sc_pkcs11_pool *, void *, CK_ULONG_PTR);
|
||||
CK_RV pool_find(struct sc_pkcs11_pool *, CK_ULONG, void **);
|
||||
CK_RV pool_find_and_delete(struct sc_pkcs11_pool *, CK_ULONG, void **);
|
||||
|
|
|
@ -134,7 +134,7 @@ CK_RV slot_initialize(int id, struct sc_pkcs11_slot *slot)
|
|||
slot->id = id;
|
||||
slot->login_user = -1;
|
||||
clear_slot_info(&slot->slot_info);
|
||||
pool_initialize(&slot->object_pool);
|
||||
pool_initialize(&slot->object_pool, POOL_TYPE_OBJECT);
|
||||
|
||||
return CKR_OK;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue