diff options
author | tb <> | 2018-04-14 07:09:21 +0000 |
---|---|---|
committer | tb <> | 2018-04-14 07:09:21 +0000 |
commit | a32b35170819e9b07e0183d19aee21b9a246943b (patch) | |
tree | 83fef660683163befc47beedefbc0b11b71b2756 /src/lib/libcrypto/ecdsa | |
parent | 7eaeb0d1b3ae143b8adb8634c48219a657764be9 (diff) | |
download | openbsd-a32b35170819e9b07e0183d19aee21b9a246943b.tar.gz openbsd-a32b35170819e9b07e0183d19aee21b9a246943b.tar.bz2 openbsd-a32b35170819e9b07e0183d19aee21b9a246943b.zip |
make ENGINE_finish() succeed on NULL and simplify callers as in
OpenSSL commit 7c96dbcdab9 by Rich Salz.
This cleans up the caller side quite a bit and reduces the number of
lines enclosed in #ifndef OPENSSL_NO_ENGINE. codesearch.debian.net
shows that almost nothing checks the return value of ENGINE_finish().
While there, replace a few nearby 'if (!ptr)' with 'if (ptr == NULL)'.
ok jsing, tested by & ok inoguchi
Diffstat (limited to 'src/lib/libcrypto/ecdsa')
-rw-r--r-- | src/lib/libcrypto/ecdsa/ecs_lib.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/lib/libcrypto/ecdsa/ecs_lib.c b/src/lib/libcrypto/ecdsa/ecs_lib.c index 4fbe1e060b..c688a95f3b 100644 --- a/src/lib/libcrypto/ecdsa/ecs_lib.c +++ b/src/lib/libcrypto/ecdsa/ecs_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ecs_lib.c,v 1.12 2017/05/02 03:59:44 deraadt Exp $ */ | 1 | /* $OpenBSD: ecs_lib.c,v 1.13 2018/04/14 07:09:21 tb Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -96,10 +96,8 @@ ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth) | |||
96 | return 0; | 96 | return 0; |
97 | 97 | ||
98 | #ifndef OPENSSL_NO_ENGINE | 98 | #ifndef OPENSSL_NO_ENGINE |
99 | if (ecdsa->engine) { | 99 | ENGINE_finish(ecdsa->engine); |
100 | ENGINE_finish(ecdsa->engine); | 100 | ecdsa->engine = NULL; |
101 | ecdsa->engine = NULL; | ||
102 | } | ||
103 | #endif | 101 | #endif |
104 | ecdsa->meth = meth; | 102 | ecdsa->meth = meth; |
105 | 103 | ||
@@ -126,7 +124,7 @@ ECDSA_DATA_new_method(ENGINE *engine) | |||
126 | ret->engine = ENGINE_get_default_ECDSA(); | 124 | ret->engine = ENGINE_get_default_ECDSA(); |
127 | if (ret->engine) { | 125 | if (ret->engine) { |
128 | ret->meth = ENGINE_get_ECDSA(ret->engine); | 126 | ret->meth = ENGINE_get_ECDSA(ret->engine); |
129 | if (!ret->meth) { | 127 | if (ret->meth == NULL) { |
130 | ECDSAerror(ERR_R_ENGINE_LIB); | 128 | ECDSAerror(ERR_R_ENGINE_LIB); |
131 | ENGINE_finish(ret->engine); | 129 | ENGINE_finish(ret->engine); |
132 | free(ret); | 130 | free(ret); |
@@ -164,8 +162,7 @@ ecdsa_data_free(void *data) | |||
164 | ECDSA_DATA *r = (ECDSA_DATA *)data; | 162 | ECDSA_DATA *r = (ECDSA_DATA *)data; |
165 | 163 | ||
166 | #ifndef OPENSSL_NO_ENGINE | 164 | #ifndef OPENSSL_NO_ENGINE |
167 | if (r->engine) | 165 | ENGINE_finish(r->engine); |
168 | ENGINE_finish(r->engine); | ||
169 | #endif | 166 | #endif |
170 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDSA, r, &r->ex_data); | 167 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDSA, r, &r->ex_data); |
171 | 168 | ||