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/ecdsa/ecs_lib.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/lib/libcrypto/ecdsa/ecs_lib.c') 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 @@ -/* $OpenBSD: ecs_lib.c,v 1.12 2017/05/02 03:59:44 deraadt Exp $ */ +/* $OpenBSD: ecs_lib.c,v 1.13 2018/04/14 07:09:21 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2005 The OpenSSL Project. All rights reserved. * @@ -96,10 +96,8 @@ ECDSA_set_method(EC_KEY *eckey, const ECDSA_METHOD *meth) return 0; #ifndef OPENSSL_NO_ENGINE - if (ecdsa->engine) { - ENGINE_finish(ecdsa->engine); - ecdsa->engine = NULL; - } + ENGINE_finish(ecdsa->engine); + ecdsa->engine = NULL; #endif ecdsa->meth = meth; @@ -126,7 +124,7 @@ ECDSA_DATA_new_method(ENGINE *engine) ret->engine = ENGINE_get_default_ECDSA(); if (ret->engine) { ret->meth = ENGINE_get_ECDSA(ret->engine); - if (!ret->meth) { + if (ret->meth == NULL) { ECDSAerror(ERR_R_ENGINE_LIB); ENGINE_finish(ret->engine); free(ret); @@ -164,8 +162,7 @@ ecdsa_data_free(void *data) ECDSA_DATA *r = (ECDSA_DATA *)data; #ifndef OPENSSL_NO_ENGINE - if (r->engine) - ENGINE_finish(r->engine); + ENGINE_finish(r->engine); #endif CRYPTO_free_ex_data(CRYPTO_EX_INDEX_ECDSA, r, &r->ex_data); -- cgit v1.2.3-55-g6feb