From a32b35170819e9b07e0183d19aee21b9a246943b Mon Sep 17 00:00:00 2001 From: tb <> Date: Sat, 14 Apr 2018 07:09:21 +0000 Subject: 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 --- src/lib/libcrypto/dh/dh_lib.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/lib/libcrypto/dh/dh_lib.c') diff --git a/src/lib/libcrypto/dh/dh_lib.c b/src/lib/libcrypto/dh/dh_lib.c index e02ce7455a..8a7f9386c7 100644 --- a/src/lib/libcrypto/dh/dh_lib.c +++ b/src/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); -- cgit v1.2.3-55-g6feb