From 75dda5e86ff224af23be99eeac84b6024b9424c0 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Mon, 11 Feb 2019 20:20:50 +0000 Subject: [PATCH] Fix crash on entering wrong passphrase. When I added the new call to ssh_key_invalid the other day, I forgot to avoid calling it if the key is NULL (and therefore even more obviously invalid). --- ssh2userauth.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/ssh2userauth.c b/ssh2userauth.c index 1d6f0d9c..69592a81 100644 --- a/ssh2userauth.c +++ b/ssh2userauth.c @@ -853,22 +853,22 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl) s->suppress_wait_for_response_packet = true; break; /* try something else */ } - } - - /* FIXME: if we ever support variable signature - * flags, this is somewhere they'll need to be - * put */ - char *invalid = ssh_key_invalid(key->key, 0); - if (invalid) { - ppl_printf("Cannot use this private key (%s)\r\n", - invalid); - ssh_key_free(key->key); - sfree(key->comment); - sfree(key); - sfree(invalid); - key = NULL; - s->suppress_wait_for_response_packet = true; - break; /* try something else */ + } else { + /* FIXME: if we ever support variable signature + * flags, this is somewhere they'll need to be + * put */ + char *invalid = ssh_key_invalid(key->key, 0); + if (invalid) { + ppl_printf("Cannot use this private key (%s)\r\n", + invalid); + ssh_key_free(key->key); + sfree(key->comment); + sfree(key); + sfree(invalid); + key = NULL; + s->suppress_wait_for_response_packet = true; + break; /* try something else */ + } } }