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/dsa/dsa_lib.c | |
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/dsa/dsa_lib.c')
-rw-r--r-- | src/lib/libcrypto/dsa/dsa_lib.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/lib/libcrypto/dsa/dsa_lib.c b/src/lib/libcrypto/dsa/dsa_lib.c index 8190d07348..d5fdd6e78e 100644 --- a/src/lib/libcrypto/dsa/dsa_lib.c +++ b/src/lib/libcrypto/dsa/dsa_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: dsa_lib.c,v 1.28 2018/02/20 17:52:27 tb Exp $ */ | 1 | /* $OpenBSD: dsa_lib.c,v 1.29 2018/04/14 07:09:21 tb 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 | * |
@@ -108,10 +108,8 @@ DSA_set_method(DSA *dsa, const DSA_METHOD *meth) | |||
108 | if (mtmp->finish) | 108 | if (mtmp->finish) |
109 | mtmp->finish(dsa); | 109 | mtmp->finish(dsa); |
110 | #ifndef OPENSSL_NO_ENGINE | 110 | #ifndef OPENSSL_NO_ENGINE |
111 | if (dsa->engine) { | 111 | ENGINE_finish(dsa->engine); |
112 | ENGINE_finish(dsa->engine); | 112 | dsa->engine = NULL; |
113 | dsa->engine = NULL; | ||
114 | } | ||
115 | #endif | 113 | #endif |
116 | dsa->meth = meth; | 114 | dsa->meth = meth; |
117 | if (meth->init) | 115 | if (meth->init) |
@@ -142,7 +140,7 @@ DSA_new_method(ENGINE *engine) | |||
142 | ret->engine = ENGINE_get_default_DSA(); | 140 | ret->engine = ENGINE_get_default_DSA(); |
143 | if (ret->engine) { | 141 | if (ret->engine) { |
144 | ret->meth = ENGINE_get_DSA(ret->engine); | 142 | ret->meth = ENGINE_get_DSA(ret->engine); |
145 | if (!ret->meth) { | 143 | if (ret->meth == NULL) { |
146 | DSAerror(ERR_R_ENGINE_LIB); | 144 | DSAerror(ERR_R_ENGINE_LIB); |
147 | ENGINE_finish(ret->engine); | 145 | ENGINE_finish(ret->engine); |
148 | free(ret); | 146 | free(ret); |
@@ -170,8 +168,7 @@ DSA_new_method(ENGINE *engine) | |||
170 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); | 168 | CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); |
171 | if (ret->meth->init != NULL && !ret->meth->init(ret)) { | 169 | if (ret->meth->init != NULL && !ret->meth->init(ret)) { |
172 | #ifndef OPENSSL_NO_ENGINE | 170 | #ifndef OPENSSL_NO_ENGINE |
173 | if (ret->engine) | 171 | ENGINE_finish(ret->engine); |
174 | ENGINE_finish(ret->engine); | ||
175 | #endif | 172 | #endif |
176 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); | 173 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, ret, &ret->ex_data); |
177 | free(ret); | 174 | free(ret); |
@@ -196,8 +193,7 @@ DSA_free(DSA *r) | |||
196 | if (r->meth->finish) | 193 | if (r->meth->finish) |
197 | r->meth->finish(r); | 194 | r->meth->finish(r); |
198 | #ifndef OPENSSL_NO_ENGINE | 195 | #ifndef OPENSSL_NO_ENGINE |
199 | if (r->engine) | 196 | ENGINE_finish(r->engine); |
200 | ENGINE_finish(r->engine); | ||
201 | #endif | 197 | #endif |
202 | 198 | ||
203 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data); | 199 | CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DSA, r, &r->ex_data); |