X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=import.c;h=adf68777dcd96de71faef9e3de49f5a0aed0ddf1;hb=00bcf6ecbc38b79579c09b25dcf848c159513f5a;hp=340785bdbd6000aead4857bd31dea4cad4aa5c02;hpb=984fe3dde809681f91d72152a4f96e91d79a2855;p=PuTTY.git diff --git a/import.c b/import.c index 340785bd..adf68777 100644 --- a/import.c +++ b/import.c @@ -1543,18 +1543,14 @@ struct ssh2_userkey *openssh_new_read(const Filename *filename, const char **errmsg_p) { struct openssh_new_key *key = load_openssh_new_key(filename, errmsg_p); - struct ssh2_userkey *retkey; + struct ssh2_userkey *retkey = NULL; int i; struct ssh2_userkey *retval = NULL; const char *errmsg; - unsigned char *blob; - int blobsize = 0; unsigned checkint0, checkint1; const void *priv, *string; int privlen, stringlen, key_index; - const struct ssh_signkey *alg; - - blob = NULL; + const struct ssh_signkey *alg = NULL; if (!key) return NULL; @@ -1678,10 +1674,10 @@ struct ssh2_userkey *openssh_new_read(const Filename *filename, (const unsigned char *)thiskey); if (key_index == key->key_wanted) { retkey = snew(struct ssh2_userkey); + retkey->comment = NULL; retkey->alg = alg; retkey->data = alg->openssh_createkey(alg, &thiskey, &thiskeylen); if (!retkey->data) { - sfree(retkey); errmsg = "unable to create key data structure"; goto error; } @@ -1718,11 +1714,16 @@ struct ssh2_userkey *openssh_new_read(const Filename *filename, errmsg = NULL; /* no error */ retval = retkey; + retkey = NULL; /* prevent the free */ error: - if (blob) { - smemclr(blob, blobsize); - sfree(blob); + if (retkey) { + sfree(retkey->comment); + if (retkey->data) { + assert(alg); + alg->freekey(retkey->data); + } + sfree(retkey); } smemclr(key->keyblob, key->keyblob_size); sfree(key->keyblob);