diff options
author | miod <> | 2014-07-09 13:30:00 +0000 |
---|---|---|
committer | miod <> | 2014-07-09 13:30:00 +0000 |
commit | d0c92522d6f628993af02705f5a3143317fc84dc (patch) | |
tree | 427c3a93b8db1cf0c0fd6ce74a69b827ab002d17 | |
parent | 7b0280e96c976103d66ebabe5a23f4f9e18a88f1 (diff) | |
download | openbsd-d0c92522d6f628993af02705f5a3143317fc84dc.tar.gz openbsd-d0c92522d6f628993af02705f5a3143317fc84dc.tar.bz2 openbsd-d0c92522d6f628993af02705f5a3143317fc84dc.zip |
Simplify error path of DH_check_pub_key()
-rw-r--r-- | src/lib/libcrypto/dh/dh_check.c | 12 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/dh/dh_check.c | 12 |
2 files changed, 8 insertions, 16 deletions
diff --git a/src/lib/libcrypto/dh/dh_check.c b/src/lib/libcrypto/dh/dh_check.c index 1df8f4cdc7..070a33081a 100644 --- a/src/lib/libcrypto/dh/dh_check.c +++ b/src/lib/libcrypto/dh/dh_check.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dh_check.c,v 1.11 2014/07/09 13:26:47 miod Exp $ */ | 1 | /* $OpenBSD: dh_check.c,v 1.12 2014/07/09 13:30:00 miod Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -124,13 +124,12 @@ err: | |||
124 | int | 124 | int |
125 | DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret) | 125 | DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret) |
126 | { | 126 | { |
127 | int ok = 0; | ||
128 | BIGNUM *q = NULL; | 127 | BIGNUM *q = NULL; |
129 | 128 | ||
130 | *ret = 0; | 129 | *ret = 0; |
131 | q = BN_new(); | 130 | q = BN_new(); |
132 | if (q == NULL) | 131 | if (q == NULL) |
133 | goto err; | 132 | return 0; |
134 | BN_set_word(q, 1); | 133 | BN_set_word(q, 1); |
135 | if (BN_cmp(pub_key, q) <= 0) | 134 | if (BN_cmp(pub_key, q) <= 0) |
136 | *ret |= DH_CHECK_PUBKEY_TOO_SMALL; | 135 | *ret |= DH_CHECK_PUBKEY_TOO_SMALL; |
@@ -139,9 +138,6 @@ DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret) | |||
139 | if (BN_cmp(pub_key, q) >= 0) | 138 | if (BN_cmp(pub_key, q) >= 0) |
140 | *ret |= DH_CHECK_PUBKEY_TOO_LARGE; | 139 | *ret |= DH_CHECK_PUBKEY_TOO_LARGE; |
141 | 140 | ||
142 | ok = 1; | 141 | BN_free(q); |
143 | err: | 142 | return 1; |
144 | if (q != NULL) | ||
145 | BN_free(q); | ||
146 | return ok; | ||
147 | } | 143 | } |
diff --git a/src/lib/libssl/src/crypto/dh/dh_check.c b/src/lib/libssl/src/crypto/dh/dh_check.c index 1df8f4cdc7..070a33081a 100644 --- a/src/lib/libssl/src/crypto/dh/dh_check.c +++ b/src/lib/libssl/src/crypto/dh/dh_check.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dh_check.c,v 1.11 2014/07/09 13:26:47 miod Exp $ */ | 1 | /* $OpenBSD: dh_check.c,v 1.12 2014/07/09 13:30:00 miod Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -124,13 +124,12 @@ err: | |||
124 | int | 124 | int |
125 | DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret) | 125 | DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret) |
126 | { | 126 | { |
127 | int ok = 0; | ||
128 | BIGNUM *q = NULL; | 127 | BIGNUM *q = NULL; |
129 | 128 | ||
130 | *ret = 0; | 129 | *ret = 0; |
131 | q = BN_new(); | 130 | q = BN_new(); |
132 | if (q == NULL) | 131 | if (q == NULL) |
133 | goto err; | 132 | return 0; |
134 | BN_set_word(q, 1); | 133 | BN_set_word(q, 1); |
135 | if (BN_cmp(pub_key, q) <= 0) | 134 | if (BN_cmp(pub_key, q) <= 0) |
136 | *ret |= DH_CHECK_PUBKEY_TOO_SMALL; | 135 | *ret |= DH_CHECK_PUBKEY_TOO_SMALL; |
@@ -139,9 +138,6 @@ DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret) | |||
139 | if (BN_cmp(pub_key, q) >= 0) | 138 | if (BN_cmp(pub_key, q) >= 0) |
140 | *ret |= DH_CHECK_PUBKEY_TOO_LARGE; | 139 | *ret |= DH_CHECK_PUBKEY_TOO_LARGE; |
141 | 140 | ||
142 | ok = 1; | 141 | BN_free(q); |
143 | err: | 142 | return 1; |
144 | if (q != NULL) | ||
145 | BN_free(q); | ||
146 | return ok; | ||
147 | } | 143 | } |