pkcs11: move the slot list size check to slot creation.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4419 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
bfe5b4a965
commit
ea7a0ac9a1
|
@ -398,7 +398,7 @@ CK_RV C_GetSlotList(CK_BBOOL tokenPresent, /* only slots with token prese
|
||||||
}
|
}
|
||||||
|
|
||||||
numMatches = 0;
|
numMatches = 0;
|
||||||
for (i=0; i<list_size(&virtual_slots) && i<sc_pkcs11_conf.max_virtual_slots; i++) {
|
for (i=0; i<list_size(&virtual_slots); i++) {
|
||||||
slot = (sc_pkcs11_slot_t *) list_get_at(&virtual_slots, i);
|
slot = (sc_pkcs11_slot_t *) list_get_at(&virtual_slots, i);
|
||||||
if (!tokenPresent || (slot->slot_info.flags & CKF_TOKEN_PRESENT))
|
if (!tokenPresent || (slot->slot_info.flags & CKF_TOKEN_PRESENT))
|
||||||
found[numMatches++] = slot->id;
|
found[numMatches++] = slot->id;
|
||||||
|
@ -653,8 +653,7 @@ again:
|
||||||
r = sc_wait_for_event(context, mask, &found, &events, -1, &reader_states);
|
r = sc_wait_for_event(context, mask, &found, &events, -1, &reader_states);
|
||||||
if (sc_pkcs11_conf.plug_and_play && events & SC_EVENT_READER_ATTACHED) {
|
if (sc_pkcs11_conf.plug_and_play && events & SC_EVENT_READER_ATTACHED) {
|
||||||
/* NSS/Firefox Triggers a C_GetSlotList(NULL) only if a slot ID is returned that it does not know yet
|
/* NSS/Firefox Triggers a C_GetSlotList(NULL) only if a slot ID is returned that it does not know yet
|
||||||
Change the first hotplug slot id on every call to make this happen.
|
Change the first hotplug slot id on every call to make this happen. */
|
||||||
*/
|
|
||||||
sc_pkcs11_slot_t *hotplug_slot = list_get_at(&virtual_slots, 0);
|
sc_pkcs11_slot_t *hotplug_slot = list_get_at(&virtual_slots, 0);
|
||||||
*pSlot= hotplug_slot->id -1;
|
*pSlot= hotplug_slot->id -1;
|
||||||
|
|
||||||
|
|
|
@ -77,10 +77,13 @@ CK_RV create_slot(sc_reader_t *reader)
|
||||||
{
|
{
|
||||||
struct sc_pkcs11_slot *slot;
|
struct sc_pkcs11_slot *slot;
|
||||||
|
|
||||||
|
if (list_size(&virtual_slots) >= sc_pkcs11_conf.max_virtual_slots)
|
||||||
|
return CKR_FUNCTION_FAILED;
|
||||||
|
|
||||||
slot = (struct sc_pkcs11_slot *)calloc(1, sizeof(struct sc_pkcs11_slot));
|
slot = (struct sc_pkcs11_slot *)calloc(1, sizeof(struct sc_pkcs11_slot));
|
||||||
if (!slot)
|
if (!slot)
|
||||||
return CKR_HOST_MEMORY;
|
return CKR_HOST_MEMORY;
|
||||||
|
|
||||||
list_append(&virtual_slots, slot);
|
list_append(&virtual_slots, slot);
|
||||||
slot->login_user = -1;
|
slot->login_user = -1;
|
||||||
slot->id = (CK_SLOT_ID) list_locate(&virtual_slots, slot);
|
slot->id = (CK_SLOT_ID) list_locate(&virtual_slots, slot);
|
||||||
|
|
Loading…
Reference in New Issue