pkcs11: Ticket #353: in pkcs15init framework allocate only one slot with uninitialized token ...

aldo, when allocating existing slot to the card, return an error if there is no more free virtual slot.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5434 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
vtarasov 2011-05-09 17:11:13 +00:00
parent 1e025a0ded
commit 16abe7f3a7
2 changed files with 5 additions and 5 deletions

View File

@ -55,15 +55,15 @@ static CK_RV pkcs15init_create_tokens(struct sc_pkcs11_card *p11card)
{
struct sc_profile *profile;
struct sc_pkcs11_slot *slot;
int rc;
profile = (struct sc_profile *) p11card->fw_data;
while (slot_allocate(&slot, p11card) == CKR_OK) {
rc = slot_allocate(&slot, p11card);
if (rc == CKR_OK) {
CK_TOKEN_INFO_PTR pToken = &slot->token_info;
const char *string;
if (sc_pkcs11_conf.hide_empty_tokens)
continue;
slot->slot_info.flags |= CKF_TOKEN_PRESENT;
strcpy_bp(pToken->model, "PKCS #15 SCard", 16);

View File

@ -287,7 +287,7 @@ CK_RV slot_allocate(struct sc_pkcs11_slot ** slot, struct sc_pkcs11_card * card)
if (tmp_slot->reader == card->reader && tmp_slot->card == NULL)
break;
}
if (!tmp_slot)
if (!tmp_slot || (i == list_size(&virtual_slots)))
return CKR_FUNCTION_FAILED;
sc_debug(context, SC_LOG_DEBUG_NORMAL, "Allocated slot 0x%lx for card in reader %s", tmp_slot->id,
card->reader->name);