From: simon 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://git.distorted.org.uk/u/mdw/putty/commitdiff_plain/25d3a4a3fd89d2814b9a361f2a8ac70125203761 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: svn://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; }