From 2766b9e56c778d3cbed93aeec5821363a4277c52 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 15 Jun 2022 16:40:54 +0200 Subject: [PATCH] agent,ssh: Fix for make not-inserted OpenPGP.3 keys available for SSH. * agent/command-ssh.c (ssh_send_available_keys): Do not bump key_counter for ignored keys. Also use opt.debug instead of opt.verbose and fix a memory leak. -- The error shown by "ssh-add -l" before this fix was: error fetching identities: incomplete messag Fixes-commit: 193fcc2f7a8cca5240ce50499c54f99235a87e1c GnuPG-bug-id: 5996 --- agent/command-ssh.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/agent/command-ssh.c b/agent/command-ssh.c index 8634ec01a..b52604b70 100644 --- a/agent/command-ssh.c +++ b/agent/command-ssh.c @@ -2582,7 +2582,7 @@ ssh_send_available_keys (ctrl_t ctrl, estream_t key_blobs, u32 *key_counter_p) xfree (cardsn); if (err) { - if (opt.verbose) + if (opt.debug) gcry_log_debugsxp ("pubkey", key_public); if (gpg_err_code (err) == GPG_ERR_UNKNOWN_CURVE || gpg_err_code (err) == GPG_ERR_INV_CURVE) @@ -2594,12 +2594,13 @@ ssh_send_available_keys (ctrl_t ctrl, estream_t key_blobs, u32 *key_counter_p) else { gcry_sexp_release (key_public); - break; + break; /* the readdir loop. */ } } + else /* Success */ + (*key_counter_p)++; gcry_sexp_release (key_public); - (*key_counter_p)++; } gnupg_closedir (dir); @@ -2616,7 +2617,7 @@ ssh_send_available_keys (ctrl_t ctrl, estream_t key_blobs, u32 *key_counter_p) xfree (cardsn); if (err) { - if (opt.verbose) + if (opt.debug) gcry_log_debugsxp ("pubkey", key_public); if (gpg_err_code (err) == GPG_ERR_UNKNOWN_CURVE || gpg_err_code (err) == GPG_ERR_INV_CURVE) @@ -2631,8 +2632,10 @@ ssh_send_available_keys (ctrl_t ctrl, estream_t key_blobs, u32 *key_counter_p) break; } } - else + else /* Success. */ (*key_counter_p)++; + + gcry_sexp_release (key_public); } agent_card_free_keyinfo (keyinfo_on_cards);