From 0415b80227c52620bece3ae7502f38f24a23e59d Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 25 Jan 2019 19:12:32 +0100 Subject: [PATCH] scd: Improve app selection for app "undefined". * scd/app.c (app_new_register): Don't bail out early in undefined mode. Signed-off-by: Werner Koch --- scd/app.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/scd/app.c b/scd/app.c index 8e0955538..219cee68d 100644 --- a/scd/app.c +++ b/scd/app.c @@ -305,21 +305,27 @@ app_new_register (int slot, ctrl_t ctrl, const char *name, } } - /* For certain error codes, there is no need to try more. */ - if (gpg_err_code (err) == GPG_ERR_CARD_NOT_PRESENT - || gpg_err_code (err) == GPG_ERR_ENODEV) - goto leave; - /* Figure out the application to use. */ if (want_undefined) { /* We switch to the "undefined" application only if explicitly requested. */ app->apptype = "UNDEFINED"; + /* Clear the error so that we don't run through the application + * selection chain. */ err = 0; } else - err = gpg_error (GPG_ERR_NOT_FOUND); + { + /* For certain error codes, there is no need to try more. */ + if (gpg_err_code (err) == GPG_ERR_CARD_NOT_PRESENT + || gpg_err_code (err) == GPG_ERR_ENODEV) + goto leave; + + /* Set a default error so that we run through the application + * selecion chain. */ + err = gpg_error (GPG_ERR_NOT_FOUND); + } if (err && is_app_allowed ("openpgp") && (!name || !strcmp (name, "openpgp")))