summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNiels Provos <provos@cvs.openbsd.org>2001-03-28 22:04:58 +0000
committerNiels Provos <provos@cvs.openbsd.org>2001-03-28 22:04:58 +0000
commite1e73b66e5502e092c00c3997d4682ef1cd04bd9 (patch)
tree3f37735d7f905d2ae527476a84b9356640da7a71 /usr.bin
parent30524a30092ca2c6143c9c15e3322bb9e7bd2a4b (diff)
more sanity checking on primes file
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/dh.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/usr.bin/ssh/dh.c b/usr.bin/ssh/dh.c
index 5f441ee1c81..636758fa8bb 100644
--- a/usr.bin/ssh/dh.c
+++ b/usr.bin/ssh/dh.c
@@ -23,7 +23,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: dh.c,v 1.9 2001/03/27 17:46:49 provos Exp $");
+RCSID("$OpenBSD: dh.c,v 1.10 2001/03/28 22:04:57 provos Exp $");
#include "xmalloc.h"
@@ -79,18 +79,21 @@ parse_prime(int linenum, char *line, struct dhgroup *dhg)
goto fail;
dhg->g = BN_new();
- if (BN_hex2bn(&dhg->g, gen) < 0) {
- BN_free(dhg->g);
- goto fail;
- }
dhg->p = BN_new();
- if (BN_hex2bn(&dhg->p, prime) < 0) {
- BN_free(dhg->g);
- BN_free(dhg->p);
- goto fail;
- }
+ if (BN_hex2bn(&dhg->g, gen) < 0)
+ goto failclean;
+
+ if (BN_hex2bn(&dhg->p, prime) < 0)
+ goto failclean;
+
+ if (BN_num_bits(dhg->p) != dhg->size)
+ goto failclean;
return (1);
+
+ failclean:
+ BN_free(dhg->g);
+ BN_free(dhg->p);
fail:
error("Bad prime description in line %d", linenum);
return (0);