diff options
author | Theo Buehler <tb@cvs.openbsd.org> | 2018-04-14 07:18:38 +0000 |
---|---|---|
committer | Theo Buehler <tb@cvs.openbsd.org> | 2018-04-14 07:18:38 +0000 |
commit | 714d8570c619e443b1d898a740a65887fab962b3 (patch) | |
tree | 2ceb7e2cd50b8659748acec0be2742f0460ddfa4 /lib/libcrypto/engine | |
parent | 364b319f72ecb5c2f1e58716cf073863162c78a8 (diff) |
Make ENGINE_free() succeed on NULL. Matches OpenSSL's behavior and
simplifies the caller side.
tested by & ok inoguchi; discussed with schwarze
Diffstat (limited to 'lib/libcrypto/engine')
-rw-r--r-- | lib/libcrypto/engine/eng_aesni.c | 12 | ||||
-rw-r--r-- | lib/libcrypto/engine/eng_cnf.c | 5 | ||||
-rw-r--r-- | lib/libcrypto/engine/eng_lib.c | 8 | ||||
-rw-r--r-- | lib/libcrypto/engine/eng_openssl.c | 6 | ||||
-rw-r--r-- | lib/libcrypto/engine/eng_padlock.c | 21 |
5 files changed, 25 insertions, 27 deletions
diff --git a/lib/libcrypto/engine/eng_aesni.c b/lib/libcrypto/engine/eng_aesni.c index cd14bbc8cd4..586f74792ac 100644 --- a/lib/libcrypto/engine/eng_aesni.c +++ b/lib/libcrypto/engine/eng_aesni.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_aesni.c,v 1.10 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: eng_aesni.c,v 1.11 2018/04/14 07:18:37 tb Exp $ */ /* * Support for Intel AES-NI intruction set * Author: Huang Ying <ying.huang@intel.com> @@ -102,12 +102,12 @@ void ENGINE_load_aesni(void) /* On non-x86 CPUs it just returns. */ #ifdef COMPILE_HW_AESNI ENGINE *toadd = ENGINE_aesni(); - if (!toadd) + if (toadd == NULL) return; - ENGINE_add (toadd); - ENGINE_register_complete (toadd); - ENGINE_free (toadd); - ERR_clear_error (); + ENGINE_add(toadd); + ENGINE_register_complete(toadd); + ENGINE_free(toadd); + ERR_clear_error(); #endif } diff --git a/lib/libcrypto/engine/eng_cnf.c b/lib/libcrypto/engine/eng_cnf.c index 2ac077d4920..24358af8cd2 100644 --- a/lib/libcrypto/engine/eng_cnf.c +++ b/lib/libcrypto/engine/eng_cnf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_cnf.c,v 1.14 2017/01/29 17:49:23 beck Exp $ */ +/* $OpenBSD: eng_cnf.c,v 1.15 2018/04/14 07:18:37 tb Exp $ */ /* Written by Stephen Henson (steve@openssl.org) for the OpenSSL * project 2001. */ @@ -200,8 +200,7 @@ err: "section=%s, name=%s, value=%s", ecmd->section, ecmd->name, ecmd->value); } - if (e) - ENGINE_free(e); + ENGINE_free(e); return ret; } diff --git a/lib/libcrypto/engine/eng_lib.c b/lib/libcrypto/engine/eng_lib.c index 11ad7711097..1aedcb18c66 100644 --- a/lib/libcrypto/engine/eng_lib.c +++ b/lib/libcrypto/engine/eng_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_lib.c,v 1.13 2018/03/17 16:20:01 beck Exp $ */ +/* $OpenBSD: eng_lib.c,v 1.14 2018/04/14 07:18:37 tb Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ @@ -115,10 +115,8 @@ engine_free_util(ENGINE *e, int locked) { int i; - if (e == NULL) { - ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); - return 0; - } + if (e == NULL) + return 1; if (locked) i = CRYPTO_add(&e->struct_ref, -1, CRYPTO_LOCK_ENGINE); else diff --git a/lib/libcrypto/engine/eng_openssl.c b/lib/libcrypto/engine/eng_openssl.c index 6154aebdee7..f8f6c8f58cd 100644 --- a/lib/libcrypto/engine/eng_openssl.c +++ b/lib/libcrypto/engine/eng_openssl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_openssl.c,v 1.12 2015/12/07 03:30:09 bcook Exp $ */ +/* $OpenBSD: eng_openssl.c,v 1.13 2018/04/14 07:18:37 tb Exp $ */ /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL * project 2000. */ @@ -177,7 +177,7 @@ engine_openssl(void) { ENGINE *ret = ENGINE_new(); - if (!ret) + if (ret == NULL) return NULL; if (!bind_helper(ret)) { ENGINE_free(ret); @@ -191,7 +191,7 @@ ENGINE_load_openssl(void) { ENGINE *toadd = engine_openssl(); - if (!toadd) + if (toadd == NULL) return; (void) ENGINE_add(toadd); /* If the "add" worked, it gets a structural reference. So either way, diff --git a/lib/libcrypto/engine/eng_padlock.c b/lib/libcrypto/engine/eng_padlock.c index 4f2d426a068..0281ab810c6 100644 --- a/lib/libcrypto/engine/eng_padlock.c +++ b/lib/libcrypto/engine/eng_padlock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: eng_padlock.c,v 1.15 2016/11/04 13:56:05 miod Exp $ */ +/* $OpenBSD: eng_padlock.c,v 1.16 2018/04/14 07:18:37 tb Exp $ */ /* * Support for VIA PadLock Advanced Cryptography Engine (ACE) * Written by Michal Ludvig <michal@logix.cz> @@ -108,19 +108,21 @@ #ifdef OPENSSL_NO_DYNAMIC_ENGINE #ifdef COMPILE_HW_PADLOCK -static ENGINE *ENGINE_padlock (void); +static ENGINE *ENGINE_padlock(void); #endif -void ENGINE_load_padlock (void) +void +ENGINE_load_padlock(void) { /* On non-x86 CPUs it just returns. */ #ifdef COMPILE_HW_PADLOCK - ENGINE *toadd = ENGINE_padlock (); - if (!toadd) + ENGINE *toadd = ENGINE_padlock(); + + if (toadd == NULL) return; - ENGINE_add (toadd); - ENGINE_free (toadd); - ERR_clear_error (); + ENGINE_add(toadd); + ENGINE_free(toadd); + ERR_clear_error(); #endif } @@ -203,9 +205,8 @@ ENGINE_padlock(void) { ENGINE *eng = ENGINE_new(); - if (!eng) { + if (eng == NULL) return NULL; - } if (!padlock_bind_helper(eng)) { ENGINE_free(eng); |