]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
rsa2_pubkey_bits: Cope correctly with a NULL return from rsa2_newkey()
authorBen Harris <bjh21@bjh21.me.uk>
Fri, 9 Oct 2015 23:58:11 +0000 (00:58 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Sat, 24 Oct 2015 21:32:59 +0000 (22:32 +0100)
Dereferencing it is not correct.
Bug found with the help of afl-fuzz.

Conflicts:
sshrsa.c

sshrsa.c

index 25f9cf7e63b9a6cf8c2fa49a3387f77d06337cfa..5c1991effe9d265558ae2117cfada116b0142baa 100644 (file)
--- a/sshrsa.c
+++ b/sshrsa.c
@@ -768,6 +768,8 @@ static int rsa2_pubkey_bits(void *blob, int len)
     int ret;
 
     rsa = rsa2_newkey((char *) blob, len);
+    if (!rsa)
+       return -1;
     ret = bignum_bitcount(rsa->modulus);
     rsa2_freekey(rsa);