diff options
author | 2018-04-14 07:09:21 +0000 | |
---|---|---|
committer | 2018-04-14 07:09:21 +0000 | |
commit | 341fd9e0365d25e6e931af82db9dcc52a587c361 (patch) | |
tree | b3b2db2a1c48d8b97f1ebbac427eef9f1cb68e4f /lib/libcrypto/evp/p_lib.c | |
parent | account for the meltdown pdir page in pmap stats (diff) | |
download | wireguard-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/evp/p_lib.c')
-rw-r--r-- | lib/libcrypto/evp/p_lib.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/lib/libcrypto/evp/p_lib.c b/lib/libcrypto/evp/p_lib.c index 811fe0c86d6..b14c95f14df 100644 --- a/lib/libcrypto/evp/p_lib.c +++ b/lib/libcrypto/evp/p_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: p_lib.c,v 1.20 2018/02/20 18:05:28 tb Exp $ */ +/* $OpenBSD: p_lib.c,v 1.21 2018/04/14 07:09:21 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -229,11 +229,8 @@ pkey_set_type(EVP_PKEY *pkey, int type, const char *str, int len) if ((type == pkey->save_type) && pkey->ameth) return 1; #ifndef OPENSSL_NO_ENGINE - /* If we have an ENGINE release it */ - if (pkey->engine) { - ENGINE_finish(pkey->engine); - pkey->engine = NULL; - } + ENGINE_finish(pkey->engine); + pkey->engine = NULL; #endif } if (str) @@ -241,7 +238,7 @@ pkey_set_type(EVP_PKEY *pkey, int type, const char *str, int len) else ameth = EVP_PKEY_asn1_find(&e, type); #ifndef OPENSSL_NO_ENGINE - if (!pkey && e) + if (pkey == NULL) ENGINE_finish(e); #endif if (!ameth) { @@ -426,8 +423,7 @@ EVP_PKEY_type(int type) else ret = NID_undef; #ifndef OPENSSL_NO_ENGINE - if (e) - ENGINE_finish(e); + ENGINE_finish(e); #endif return ret; } @@ -470,10 +466,8 @@ EVP_PKEY_free_it(EVP_PKEY *x) x->pkey.ptr = NULL; } #ifndef OPENSSL_NO_ENGINE - if (x->engine) { - ENGINE_finish(x->engine); - x->engine = NULL; - } + ENGINE_finish(x->engine); + x->engine = NULL; #endif } |