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.

[originally from svn r9991]
This commit is contained in:
Simon Tatham 2013-08-04 19:34:10 +00:00
Родитель cb1df53360
Коммит 20aabc3059
1 изменённых файлов: 7 добавлений и 0 удалений

Просмотреть файл

@ -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;
}