From 7dde732f7d922e7ece7f13639d26048cb026efbb Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Fri, 10 Jan 2020 19:27:07 +0000 Subject: [PATCH] Fix missing comments in Windows Pageant. When I took the key comments out of the RSAKey / ssh2_userkey structures stored in pageant.c's trees and moved them into the new containing PageantKey structure, I forgot that that would mean Windows Pageant - which tries to read the comments _from_ those structures - would now not be able to show comments in its list box. Comments are small, so the easiest fix is just to duplicate them in both places. --- pageant.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/pageant.c b/pageant.c index cde1f473..dec74914 100644 --- a/pageant.c +++ b/pageant.c @@ -43,7 +43,7 @@ typedef struct PageantKeySort { typedef struct PageantKey { PageantKeySort sort; strbuf *public_blob; /* the true owner of sort.public_blob */ - char *comment; /* always stored separately, never in rkey/skey */ + char *comment; /* stored separately, whether or not in rkey/skey */ union { RSAKey *rkey; /* if ssh_version == 1 */ ssh2_userkey *skey; /* if ssh_version == 2 */ @@ -59,6 +59,7 @@ static void pk_free(PageantKey *pk) sfree(pk->rkey); } if (pk->sort.ssh_version == 2 && pk->skey) { + sfree(pk->skey->comment); ssh_key_free(pk->skey->key); sfree(pk->skey); } @@ -140,10 +141,8 @@ bool pageant_add_ssh1_key(RSAKey *rkey) if (add234(keytree, pk) == pk) { pk->rkey = rkey; - if (rkey->comment) { - pk->comment = rkey->comment; - rkey->comment = NULL; - } + if (rkey->comment) + pk->comment = dupstr(rkey->comment); return true; } else { pk_free(pk); @@ -161,10 +160,8 @@ bool pageant_add_ssh2_key(ssh2_userkey *skey) if (add234(keytree, pk) == pk) { pk->skey = skey; - if (skey->comment) { - pk->comment = skey->comment; - skey->comment = NULL; - } + if (skey->comment) + pk->comment = dupstr(skey->comment); return true; } else { pk_free(pk);