From d4f135c34b332f1f833617a7f1ef0bdbff5eb589 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Wed, 21 Aug 2019 09:56:44 +0900 Subject: scd: Fix switching to another APP. * scd/app.c (select_additional_application): Initialize card of APP. Break after the selection. Don't free APP if success. Signed-off-by: NIIBE Yutaka --- scd/app.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/scd/app.c b/scd/app.c index 57c4b7743..edd3174dc 100644 --- a/scd/app.c +++ b/scd/app.c @@ -723,13 +723,17 @@ select_additional_application (ctrl_t ctrl, const char *name) log_info ("error allocating app context: %s\n", gpg_strerror (err)); goto leave; } + app->card = card; /* Find the app and run the select. */ for (i=0; app_priority_list[i].apptype; i++) { if (app_priority_list[i].apptype == req_apptype && is_app_allowed (app_priority_list[i].name)) - err = app_priority_list[i].select_func (app); + { + err = app_priority_list[i].select_func (app); + break; + } } if (!app_priority_list[i].apptype || (err && gpg_err_code (err) != GPG_ERR_OBJ_TERM_STATE)) @@ -743,11 +747,12 @@ select_additional_application (ctrl_t ctrl, const char *name) app->next = card->app; card->app = app; ctrl->current_apptype = app->apptype; - log_error ("added app '%s' to the card context\n", strapptype(app->apptype)); + log_info ("added app '%s' to the card context\n", strapptype (app->apptype)); leave: unlock_card (card); - xfree (app); + if (err) + xfree (app); return err; } @@ -990,7 +995,7 @@ maybe_switch_app (ctrl_t ctrl, card_t card) app->next = card->app; card->app = app; ctrl->current_apptype = app->apptype; - log_error ("switched to '%s'\n", strapptype(app->apptype)); + log_info ("switched to '%s'\n", strapptype (app->apptype)); return 0; } -- cgit v1.2.3