reset sc_card_t during card detection
fixes https://github.com/OpenSC/OpenSC/issues/1417
This commit is contained in:
parent
6f8bfc399b
commit
2c0d1b9ab0
|
@ -261,8 +261,22 @@ int sc_connect_card(sc_reader_t *reader, sc_card_t **card_out)
|
|||
}
|
||||
}
|
||||
else {
|
||||
sc_card_t uninitialized = *card;
|
||||
sc_log(ctx, "matching built-in ATRs");
|
||||
for (i = 0; ctx->card_drivers[i] != NULL; i++) {
|
||||
/* FIXME If we had a clean API description, we'd propably get a
|
||||
* cleaner implementation of the driver's match_card and init,
|
||||
* which should normally *not* modify the card object if
|
||||
* unsuccessful. However, after years of relentless hacking, reality
|
||||
* is different: The card object is changed in virtually every card
|
||||
* driver so in order to prevent unwanted interaction, we reset the
|
||||
* card object here and hope that the card driver at least doesn't
|
||||
* allocate any internal ressources that need to be freed. If we
|
||||
* had more time, we should refactor the existing code to not
|
||||
* modify sc_card_t until complete success (possibly by combining
|
||||
* `match_card()` and `init()`) */
|
||||
*card = uninitialized;
|
||||
|
||||
struct sc_card_driver *drv = ctx->card_drivers[i];
|
||||
const struct sc_card_operations *ops = drv->ops;
|
||||
|
||||
|
|
Loading…
Reference in New Issue