X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/31a61d2103dc77fb70f5ac9cd771cfd21fd7ee88..5c58ad2d1527936b4d30891497eef48bde0fe1f3:/sshpubk.c diff --git a/sshpubk.c b/sshpubk.c index da22ee6d..3e4de1fc 100644 --- a/sshpubk.c +++ b/sshpubk.c @@ -67,10 +67,14 @@ int loadrsakey(char *filename, struct RSAKey *key, char *passphrase) { /* Next, the comment field. */ j = GET_32BIT(buf+i); - if (len-i < 4+j) goto end; i += 4+j; - /* - * FIXME: might need to use this string. - */ + i += 4; + if (len-i < j) goto end; + key->comment = malloc(j+1); + if (key->comment) { + memcpy(key->comment, buf+i, j); + key->comment[j] = '\0'; + } + i += j; /* * Decrypt remainder of buffer. @@ -80,7 +84,7 @@ int loadrsakey(char *filename, struct RSAKey *key, char *passphrase) { MD5Update(&md5c, passphrase, strlen(passphrase)); MD5Final(keybuf, &md5c); des3_decrypt_pubkey(keybuf, buf+i, (len-i+7)&~7); - memset(keybuf, 0, sizeof(buf)); /* burn the evidence */ + memset(keybuf, 0, sizeof(keybuf)); /* burn the evidence */ } /*