diff --git a/src/libopensc/card-gids.c b/src/libopensc/card-gids.c index ee27ccf3..4a79bf0b 100644 --- a/src/libopensc/card-gids.c +++ b/src/libopensc/card-gids.c @@ -2039,7 +2039,7 @@ struct sc_card_driver *sc_get_gids_driver(void) struct sc_card_driver *sc_get_gids_driver(void) { - return SC_ERROR_WRONG_CARD; + return NULL; } #endif diff --git a/src/libopensc/ctx.c b/src/libopensc/ctx.c index 95dbf89a..7045aa1a 100644 --- a/src/libopensc/ctx.c +++ b/src/libopensc/ctx.c @@ -112,7 +112,9 @@ static const struct _sc_driver_entry internal_card_drivers[] = { { "PIV-II", (void *(*)(void)) sc_get_piv_driver }, { "itacns", (void *(*)(void)) sc_get_itacns_driver }, { "isoApplet", (void *(*)(void)) sc_get_isoApplet_driver }, +#ifdef ENABLE_ZLIB { "gids", (void *(*)(void)) sc_get_gids_driver }, +#endif { "openpgp", (void *(*)(void)) sc_get_openpgp_driver }, /* The default driver should be last, as it handles all the * unrecognized cards. */ @@ -422,8 +424,7 @@ static int load_card_driver_options(sc_context_t *ctx, return SC_SUCCESS; } -static int load_card_drivers(sc_context_t *ctx, - struct _sc_ctx_options *opts) +static int load_card_drivers(sc_context_t *ctx, struct _sc_ctx_options *opts) { const struct _sc_driver_entry *ent; int drv_count; @@ -461,8 +462,14 @@ static int load_card_drivers(sc_context_t *ctx, } ctx->card_drivers[drv_count] = func(); - ctx->card_drivers[drv_count]->dll = dll; + if (ctx->card_drivers[drv_count] == NULL) { + sc_log(ctx, "Driver '%s' not available.", ent->name); + if (dll) + sc_dlclose(dll); + continue; + } + ctx->card_drivers[drv_count]->dll = dll; ctx->card_drivers[drv_count]->atr_map = NULL; ctx->card_drivers[drv_count]->natrs = 0;