From: Simon Tatham Date: Sun, 4 Aug 2013 19:34:10 +0000 (+0000) Subject: Spot when we didn't successfully create an RSA public key from a X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;ds=sidebyside;h=9e370fd636fe95587352fcbca266f610f0395791;p=PuTTY_svn.git Spot when we didn't successfully create an RSA public key from a public blob, and return a proper error in that situation rather than a struct with unhelpful NULLs in. git-svn-id: http://svn.tartarus.org/sgt/putty@9991 cda61777-01e9-0310-a592-d414129be87e --- diff --git a/sshrsa.c b/sshrsa.c index fb0bcaa9..4ec95f23 100644 --- a/sshrsa.c +++ b/sshrsa.c @@ -561,6 +561,8 @@ static Bignum getmp(char **data, int *datalen) return b; } +static void rsa2_freekey(void *key); /* forward reference */ + static void *rsa2_newkey(char *data, int len) { char *p; @@ -580,6 +582,11 @@ static void *rsa2_newkey(char *data, int len) rsa->p = rsa->q = rsa->iqmp = NULL; rsa->comment = NULL; + if (!rsa->exponent || !rsa->modulus) { + rsa2_freekey(rsa); + return NULL; + } + return rsa; }