diff --git a/src/pkcs11/pkcs11-global.c b/src/pkcs11/pkcs11-global.c index ec150c65..e2a99282 100644 --- a/src/pkcs11/pkcs11-global.c +++ b/src/pkcs11/pkcs11-global.c @@ -398,7 +398,7 @@ CK_RV C_GetSlotList(CK_BBOOL tokenPresent, /* only slots with token prese } numMatches = 0; - for (i=0; islot_info.flags & CKF_TOKEN_PRESENT)) found[numMatches++] = slot->id; @@ -653,8 +653,7 @@ again: r = sc_wait_for_event(context, mask, &found, &events, -1, &reader_states); 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 - 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); *pSlot= hotplug_slot->id -1; diff --git a/src/pkcs11/slot.c b/src/pkcs11/slot.c index e7f7796c..09a8726d 100644 --- a/src/pkcs11/slot.c +++ b/src/pkcs11/slot.c @@ -77,10 +77,13 @@ CK_RV create_slot(sc_reader_t *reader) { 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)); if (!slot) return CKR_HOST_MEMORY; - + list_append(&virtual_slots, slot); slot->login_user = -1; slot->id = (CK_SLOT_ID) list_locate(&virtual_slots, slot);