Many bugfixes including segfault in card detection and C_GetSlotInfo

now detects the cards too.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@185 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
fabled 2002-01-22 14:44:56 +00:00
parent 623e5ad1b4
commit 82a2d72e6a
3 changed files with 11 additions and 4 deletions

View File

@ -156,7 +156,7 @@ static CK_RV pkcs15_create_tokens(struct sc_pkcs11_card *p11card)
return sc_to_cryptoki_error(rv, reader);
for (i = 0; i < card->pin_count; i++) {
char tmp[32];
char tmp[33];
rv = slot_allocate(&slot, p11card);
if (rv != CKR_OK)
@ -165,7 +165,7 @@ static CK_RV pkcs15_create_tokens(struct sc_pkcs11_card *p11card)
pkcs15_init_token_info(card, &slot->token_info);
slot->fw_data = &card->pin_info[i];
sprintf(tmp, "%s (%s)", card->label, card->pin_info[i].com_attr.label);
snprintf(tmp, sizeof(tmp), "%s (%s)", card->label, card->pin_info[i].com_attr.label);
strcpy_bp(slot->token_info.label, tmp, 32);
if (card->pin_info[i].magic == SC_PKCS15_PIN_MAGIC) {
@ -498,7 +498,7 @@ CK_RV pkcs15_prkey_sign(struct sc_pkcs11_session *ses, void *obj,
return CKR_MECHANISM_INVALID;
}
debug(context, "Selected flags %X. Now computing signature.\n", flags);
debug(context, "Selected flags %X. Now computing signature. %d bytes reserved.\n", flags, *pulDataLen);
rv = sc_pkcs15_compute_signature((struct sc_pkcs15_card*) ses->slot->card->fw_data,
prkey->prkey_info,
flags,

View File

@ -166,6 +166,12 @@ CK_RV C_GetSlotInfo(CK_SLOT_ID slotID, CK_SLOT_INFO_PTR pInfo)
if (rv != CKR_OK)
return rv;
if (!(slot->slot_info.flags & CKF_TOKEN_PRESENT)) {
int i;
for (i=0; i<context->reader_count; i++)
card_detect(i);
}
debug(context, "Getting info about slot %d\n", slotID);
memcpy(pInfo, &slot->slot_info, sizeof(CK_SLOT_INFO));
return CKR_OK;

View File

@ -102,7 +102,8 @@ CK_RV card_removed(int reader)
debug(context, "%d: SmartCard removed\n", reader);
for (i=0; i<SC_PKCS11_MAX_VIRTUAL_SLOTS; i++) {
if (virtual_slots[i].card->reader == reader)
if (virtual_slots[i].card &&
virtual_slots[i].card->reader == reader)
slot_token_removed(i);
}