stop SM in case of SM errors

This commit is contained in:
Frank Morgner 2015-04-01 21:03:25 +02:00 committed by Viktor Tarasov
parent e07c4bcfbb
commit c0fac2a4f6
1 changed files with 11 additions and 1 deletions

View File

@ -140,6 +140,9 @@ sc_sm_single_transmit(struct sc_card *card, struct sc_apdu *apdu)
* Send plain APDU to the reader driver */
rv = card->reader->ops->transmit(card->reader, apdu);
LOG_FUNC_RETURN(ctx, rv);
} else {
if (rv < 0)
sc_sm_stop(card);
}
LOG_TEST_RET(ctx, rv, "get SM APDU error");
@ -147,15 +150,22 @@ sc_sm_single_transmit(struct sc_card *card, struct sc_apdu *apdu)
rv = sc_check_apdu(card, sm_apdu);
if (rv < 0) {
card->sm_ctx.ops.free_sm_apdu(card, apdu, &sm_apdu);
sc_sm_stop(card);
LOG_TEST_RET(ctx, rv, "cannot validate SM encoded APDU");
}
/* send APDU to the reader driver */
rv = card->reader->ops->transmit(card->reader, sm_apdu);
LOG_TEST_RET(ctx, rv, "unable to transmit APDU");
if (rv < 0) {
card->sm_ctx.ops.free_sm_apdu(card, apdu, &sm_apdu);
sc_sm_stop(card);
LOG_TEST_RET(ctx, rv, "unable to transmit APDU");
}
/* decode SM answer and free temporary SM related data */
rv = card->sm_ctx.ops.free_sm_apdu(card, apdu, &sm_apdu);
if (rv < 0)
sc_sm_stop(card);
LOG_FUNC_RETURN(ctx, rv);
}