diff options
author | tb <> | 2018-04-14 07:18:37 +0000 |
---|---|---|
committer | tb <> | 2018-04-14 07:18:37 +0000 |
commit | 1e9445503c3ea65f8c138ab5dc555db0f1db91a7 (patch) | |
tree | 27f20ba7d1bd380c7995e6d349ae1b5f8b90cc6d /src/lib/libcrypto | |
parent | a32b35170819e9b07e0183d19aee21b9a246943b (diff) | |
download | openbsd-1e9445503c3ea65f8c138ab5dc555db0f1db91a7.tar.gz openbsd-1e9445503c3ea65f8c138ab5dc555db0f1db91a7.tar.bz2 openbsd-1e9445503c3ea65f8c138ab5dc555db0f1db91a7.zip |
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 'src/lib/libcrypto')
-rw-r--r-- | src/lib/libcrypto/engine/eng_aesni.c | 12 | ||||
-rw-r--r-- | src/lib/libcrypto/engine/eng_cnf.c | 5 | ||||
-rw-r--r-- | src/lib/libcrypto/engine/eng_lib.c | 8 | ||||
-rw-r--r-- | src/lib/libcrypto/engine/eng_openssl.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/engine/eng_padlock.c | 21 | ||||
-rw-r--r-- | src/lib/libcrypto/ts/ts_conf.c | 5 |
6 files changed, 27 insertions, 30 deletions
diff --git a/src/lib/libcrypto/engine/eng_aesni.c b/src/lib/libcrypto/engine/eng_aesni.c index cd14bbc8cd..586f74792a 100644 --- a/src/lib/libcrypto/engine/eng_aesni.c +++ b/src/lib/libcrypto/engine/eng_aesni.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: eng_aesni.c,v 1.10 2017/01/29 17:49:23 beck Exp $ */ | 1 | /* $OpenBSD: eng_aesni.c,v 1.11 2018/04/14 07:18:37 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Support for Intel AES-NI intruction set | 3 | * Support for Intel AES-NI intruction set |
4 | * Author: Huang Ying <ying.huang@intel.com> | 4 | * Author: Huang Ying <ying.huang@intel.com> |
@@ -102,12 +102,12 @@ void ENGINE_load_aesni(void) | |||
102 | /* On non-x86 CPUs it just returns. */ | 102 | /* On non-x86 CPUs it just returns. */ |
103 | #ifdef COMPILE_HW_AESNI | 103 | #ifdef COMPILE_HW_AESNI |
104 | ENGINE *toadd = ENGINE_aesni(); | 104 | ENGINE *toadd = ENGINE_aesni(); |
105 | if (!toadd) | 105 | if (toadd == NULL) |
106 | return; | 106 | return; |
107 | ENGINE_add (toadd); | 107 | ENGINE_add(toadd); |
108 | ENGINE_register_complete (toadd); | 108 | ENGINE_register_complete(toadd); |
109 | ENGINE_free (toadd); | 109 | ENGINE_free(toadd); |
110 | ERR_clear_error (); | 110 | ERR_clear_error(); |
111 | #endif | 111 | #endif |
112 | } | 112 | } |
113 | 113 | ||
diff --git a/src/lib/libcrypto/engine/eng_cnf.c b/src/lib/libcrypto/engine/eng_cnf.c index 2ac077d492..24358af8cd 100644 --- a/src/lib/libcrypto/engine/eng_cnf.c +++ b/src/lib/libcrypto/engine/eng_cnf.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: eng_cnf.c,v 1.14 2017/01/29 17:49:23 beck Exp $ */ | 1 | /* $OpenBSD: eng_cnf.c,v 1.15 2018/04/14 07:18:37 tb Exp $ */ |
2 | /* Written by Stephen Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Stephen Henson (steve@openssl.org) for the OpenSSL |
3 | * project 2001. | 3 | * project 2001. |
4 | */ | 4 | */ |
@@ -200,8 +200,7 @@ err: | |||
200 | "section=%s, name=%s, value=%s", | 200 | "section=%s, name=%s, value=%s", |
201 | ecmd->section, ecmd->name, ecmd->value); | 201 | ecmd->section, ecmd->name, ecmd->value); |
202 | } | 202 | } |
203 | if (e) | 203 | ENGINE_free(e); |
204 | ENGINE_free(e); | ||
205 | return ret; | 204 | return ret; |
206 | } | 205 | } |
207 | 206 | ||
diff --git a/src/lib/libcrypto/engine/eng_lib.c b/src/lib/libcrypto/engine/eng_lib.c index 11ad771109..1aedcb18c6 100644 --- a/src/lib/libcrypto/engine/eng_lib.c +++ b/src/lib/libcrypto/engine/eng_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: eng_lib.c,v 1.13 2018/03/17 16:20:01 beck Exp $ */ | 1 | /* $OpenBSD: eng_lib.c,v 1.14 2018/04/14 07:18:37 tb Exp $ */ |
2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | 2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL |
3 | * project 2000. | 3 | * project 2000. |
4 | */ | 4 | */ |
@@ -115,10 +115,8 @@ engine_free_util(ENGINE *e, int locked) | |||
115 | { | 115 | { |
116 | int i; | 116 | int i; |
117 | 117 | ||
118 | if (e == NULL) { | 118 | if (e == NULL) |
119 | ENGINEerror(ERR_R_PASSED_NULL_PARAMETER); | 119 | return 1; |
120 | return 0; | ||
121 | } | ||
122 | if (locked) | 120 | if (locked) |
123 | i = CRYPTO_add(&e->struct_ref, -1, CRYPTO_LOCK_ENGINE); | 121 | i = CRYPTO_add(&e->struct_ref, -1, CRYPTO_LOCK_ENGINE); |
124 | else | 122 | else |
diff --git a/src/lib/libcrypto/engine/eng_openssl.c b/src/lib/libcrypto/engine/eng_openssl.c index 6154aebdee..f8f6c8f58c 100644 --- a/src/lib/libcrypto/engine/eng_openssl.c +++ b/src/lib/libcrypto/engine/eng_openssl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: eng_openssl.c,v 1.12 2015/12/07 03:30:09 bcook Exp $ */ | 1 | /* $OpenBSD: eng_openssl.c,v 1.13 2018/04/14 07:18:37 tb Exp $ */ |
2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL | 2 | /* Written by Geoff Thorpe (geoff@geoffthorpe.net) for the OpenSSL |
3 | * project 2000. | 3 | * project 2000. |
4 | */ | 4 | */ |
@@ -177,7 +177,7 @@ engine_openssl(void) | |||
177 | { | 177 | { |
178 | ENGINE *ret = ENGINE_new(); | 178 | ENGINE *ret = ENGINE_new(); |
179 | 179 | ||
180 | if (!ret) | 180 | if (ret == NULL) |
181 | return NULL; | 181 | return NULL; |
182 | if (!bind_helper(ret)) { | 182 | if (!bind_helper(ret)) { |
183 | ENGINE_free(ret); | 183 | ENGINE_free(ret); |
@@ -191,7 +191,7 @@ ENGINE_load_openssl(void) | |||
191 | { | 191 | { |
192 | ENGINE *toadd = engine_openssl(); | 192 | ENGINE *toadd = engine_openssl(); |
193 | 193 | ||
194 | if (!toadd) | 194 | if (toadd == NULL) |
195 | return; | 195 | return; |
196 | (void) ENGINE_add(toadd); | 196 | (void) ENGINE_add(toadd); |
197 | /* If the "add" worked, it gets a structural reference. So either way, | 197 | /* If the "add" worked, it gets a structural reference. So either way, |
diff --git a/src/lib/libcrypto/engine/eng_padlock.c b/src/lib/libcrypto/engine/eng_padlock.c index 4f2d426a06..0281ab810c 100644 --- a/src/lib/libcrypto/engine/eng_padlock.c +++ b/src/lib/libcrypto/engine/eng_padlock.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: eng_padlock.c,v 1.15 2016/11/04 13:56:05 miod Exp $ */ | 1 | /* $OpenBSD: eng_padlock.c,v 1.16 2018/04/14 07:18:37 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Support for VIA PadLock Advanced Cryptography Engine (ACE) | 3 | * Support for VIA PadLock Advanced Cryptography Engine (ACE) |
4 | * Written by Michal Ludvig <michal@logix.cz> | 4 | * Written by Michal Ludvig <michal@logix.cz> |
@@ -108,19 +108,21 @@ | |||
108 | 108 | ||
109 | #ifdef OPENSSL_NO_DYNAMIC_ENGINE | 109 | #ifdef OPENSSL_NO_DYNAMIC_ENGINE |
110 | #ifdef COMPILE_HW_PADLOCK | 110 | #ifdef COMPILE_HW_PADLOCK |
111 | static ENGINE *ENGINE_padlock (void); | 111 | static ENGINE *ENGINE_padlock(void); |
112 | #endif | 112 | #endif |
113 | 113 | ||
114 | void ENGINE_load_padlock (void) | 114 | void |
115 | ENGINE_load_padlock(void) | ||
115 | { | 116 | { |
116 | /* On non-x86 CPUs it just returns. */ | 117 | /* On non-x86 CPUs it just returns. */ |
117 | #ifdef COMPILE_HW_PADLOCK | 118 | #ifdef COMPILE_HW_PADLOCK |
118 | ENGINE *toadd = ENGINE_padlock (); | 119 | ENGINE *toadd = ENGINE_padlock(); |
119 | if (!toadd) | 120 | |
121 | if (toadd == NULL) | ||
120 | return; | 122 | return; |
121 | ENGINE_add (toadd); | 123 | ENGINE_add(toadd); |
122 | ENGINE_free (toadd); | 124 | ENGINE_free(toadd); |
123 | ERR_clear_error (); | 125 | ERR_clear_error(); |
124 | #endif | 126 | #endif |
125 | } | 127 | } |
126 | 128 | ||
@@ -203,9 +205,8 @@ ENGINE_padlock(void) | |||
203 | { | 205 | { |
204 | ENGINE *eng = ENGINE_new(); | 206 | ENGINE *eng = ENGINE_new(); |
205 | 207 | ||
206 | if (!eng) { | 208 | if (eng == NULL) |
207 | return NULL; | 209 | return NULL; |
208 | } | ||
209 | 210 | ||
210 | if (!padlock_bind_helper(eng)) { | 211 | if (!padlock_bind_helper(eng)) { |
211 | ENGINE_free(eng); | 212 | ENGINE_free(eng); |
diff --git a/src/lib/libcrypto/ts/ts_conf.c b/src/lib/libcrypto/ts/ts_conf.c index c223aa3d46..41d185ee5a 100644 --- a/src/lib/libcrypto/ts/ts_conf.c +++ b/src/lib/libcrypto/ts/ts_conf.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ts_conf.c,v 1.10 2017/01/29 17:49:23 beck Exp $ */ | 1 | /* $OpenBSD: ts_conf.c,v 1.11 2018/04/14 07:18:37 tb Exp $ */ |
2 | /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL | 2 | /* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL |
3 | * project 2002. | 3 | * project 2002. |
4 | */ | 4 | */ |
@@ -248,8 +248,7 @@ err: | |||
248 | TSerror(TS_R_COULD_NOT_SET_ENGINE); | 248 | TSerror(TS_R_COULD_NOT_SET_ENGINE); |
249 | ERR_asprintf_error_data("engine:%s", name); | 249 | ERR_asprintf_error_data("engine:%s", name); |
250 | } | 250 | } |
251 | if (e) | 251 | ENGINE_free(e); |
252 | ENGINE_free(e); | ||
253 | return ret; | 252 | return ret; |
254 | } | 253 | } |
255 | 254 | ||