diff options
author | NIIBE Yutaka <[email protected]> | 2024-10-01 01:55:11 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2024-11-08 07:42:03 +0000 |
commit | 6022f10da39e512b5b3fed3869fd6579d954090c (patch) | |
tree | 2faf2e03498dc0f388f52c988aa16666309cb422 | |
parent | gpg-mail-type: Assume text/plain for missing content-type. (diff) | |
download | gnupg-6022f10da39e512b5b3fed3869fd6579d954090c.tar.gz gnupg-6022f10da39e512b5b3fed3869fd6579d954090c.zip |
gpg: Robust error handling for SCD READKEY.
* g10/keygen.c (ask_algo): List the card key only when it's valid.
--
GnuPG-bug-id: 7309
Signed-off-by: NIIBE Yutaka <[email protected]>
-rw-r--r-- | g10/keygen.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/g10/keygen.c b/g10/keygen.c index 300486504..077023f57 100644 --- a/g10/keygen.c +++ b/g10/keygen.c @@ -2478,12 +2478,14 @@ ask_algo (ctrl_t ctrl, int addmode, int *r_subkey_algo, unsigned int *r_usage, const char *keyref = kpi->idstr; int any = 0; - if (keyref - && !agent_scd_readkey (ctrl, keyref, &s_pkey, NULL)) - { - algostr = pubkey_algo_string (s_pkey, &algoid); - gcry_sexp_release (s_pkey); - } + if (!keyref) + continue; + + if (!agent_scd_readkey (ctrl, keyref, &s_pkey, NULL)) + continue; + + algostr = pubkey_algo_string (s_pkey, &algoid); + gcry_sexp_release (s_pkey); /* We need to tweak the algo in case GCRY_PK_ECC is * returned because pubkey_algo_string is not aware @@ -2556,9 +2558,9 @@ ask_algo (ctrl_t ctrl, int addmode, int *r_subkey_algo, unsigned int *r_usage, for (count=1,kpi=keypairlist; kpi; kpi = kpi->next, count++) if (count == selection) break; - if (!kpi) + if (!kpi || !kpi->algo) { - /* Just in case COUNT is zero (no keys). */ + /* Just in case no good key. */ free_keypair_info (keypairlist); goto ask_again; } |