summaryrefslogtreecommitdiffstats
path: root/lib/libcrypto/dh/dh_lib.c
diff options
context:
space:
mode:
authortb <tb@openbsd.org>2018-04-14 07:09:21 +0000
committertb <tb@openbsd.org>2018-04-14 07:09:21 +0000
commit341fd9e0365d25e6e931af82db9dcc52a587c361 (patch)
treeb3b2db2a1c48d8b97f1ebbac427eef9f1cb68e4f /lib/libcrypto/dh/dh_lib.c
parentaccount for the meltdown pdir page in pmap stats (diff)
downloadwireguard-openbsd-341fd9e0365d25e6e931af82db9dcc52a587c361.tar.xz
wireguard-openbsd-341fd9e0365d25e6e931af82db9dcc52a587c361.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 'lib/libcrypto/dh/dh_lib.c')
-rw-r--r--lib/libcrypto/dh/dh_lib.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/libcrypto/dh/dh_lib.c b/lib/libcrypto/dh/dh_lib.c
index e02ce7455a2..8a7f9386c7e 100644
--- a/lib/libcrypto/dh/dh_lib.c
+++ b/lib/libcrypto/dh/dh_lib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dh_lib.c,v 1.30 2018/02/22 16:41:04 jsing Exp $ */
+/* $OpenBSD: dh_lib.c,v 1.31 2018/04/14 07:09:21 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
@@ -98,10 +98,8 @@ DH_set_method(DH *dh, const DH_METHOD *meth)
if (mtmp->finish)
mtmp->finish(dh);
#ifndef OPENSSL_NO_ENGINE
- if (dh->engine) {
- ENGINE_finish(dh->engine);
- dh->engine = NULL;
- }
+ ENGINE_finish(dh->engine);
+ dh->engine = NULL;
#endif
dh->meth = meth;
if (meth->init)
@@ -139,7 +137,7 @@ DH_new_method(ENGINE *engine)
ret->engine = ENGINE_get_default_DH();
if(ret->engine) {
ret->meth = ENGINE_get_DH(ret->engine);
- if (!ret->meth) {
+ if (ret->meth == NULL) {
DHerror(ERR_R_ENGINE_LIB);
ENGINE_finish(ret->engine);
free(ret);
@@ -166,8 +164,7 @@ DH_new_method(ENGINE *engine)
CRYPTO_new_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data);
if (ret->meth->init != NULL && !ret->meth->init(ret)) {
#ifndef OPENSSL_NO_ENGINE
- if (ret->engine)
- ENGINE_finish(ret->engine);
+ ENGINE_finish(ret->engine);
#endif
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, ret, &ret->ex_data);
free(ret);
@@ -190,8 +187,7 @@ DH_free(DH *r)
if (r->meth->finish)
r->meth->finish(r);
#ifndef OPENSSL_NO_ENGINE
- if (r->engine)
- ENGINE_finish(r->engine);
+ ENGINE_finish(r->engine);
#endif
CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DH, r, &r->ex_data);