diff options
| author | miod <> | 2014-07-09 13:30:00 +0000 |
|---|---|---|
| committer | miod <> | 2014-07-09 13:30:00 +0000 |
| commit | a28b931f979f0e5c8736a12b3a4bc427b939c4b6 (patch) | |
| tree | 427c3a93b8db1cf0c0fd6ce74a69b827ab002d17 /src/lib/libc | |
| parent | 20bc42573a8eb2be6fdb1002a3d413e4fdebabb6 (diff) | |
| download | openbsd-a28b931f979f0e5c8736a12b3a4bc427b939c4b6.tar.gz openbsd-a28b931f979f0e5c8736a12b3a4bc427b939c4b6.tar.bz2 openbsd-a28b931f979f0e5c8736a12b3a4bc427b939c4b6.zip | |
Simplify error path of DH_check_pub_key()
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/dh/dh_check.c | 12 |
1 files changed, 4 insertions, 8 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 | } |
