diff options
| author | tb <> | 2018-04-14 07:09:21 +0000 |
|---|---|---|
| committer | tb <> | 2018-04-14 07:09:21 +0000 |
| commit | 0c5418014797b1fadca3f270eb2f140fd6f5bdf8 (patch) | |
| tree | 83fef660683163befc47beedefbc0b11b71b2756 /src/lib/libcrypto/evp/p_lib.c | |
| parent | 0c3f32384bbfe8e0484372a52a7b00027b367750 (diff) | |
| download | openbsd-0c5418014797b1fadca3f270eb2f140fd6f5bdf8.tar.gz openbsd-0c5418014797b1fadca3f270eb2f140fd6f5bdf8.tar.bz2 openbsd-0c5418014797b1fadca3f270eb2f140fd6f5bdf8.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 'src/lib/libcrypto/evp/p_lib.c')
| -rw-r--r-- | src/lib/libcrypto/evp/p_lib.c | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/lib/libcrypto/evp/p_lib.c b/src/lib/libcrypto/evp/p_lib.c index 811fe0c86d..b14c95f14d 100644 --- a/src/lib/libcrypto/evp/p_lib.c +++ b/src/lib/libcrypto/evp/p_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: p_lib.c,v 1.20 2018/02/20 18:05:28 tb Exp $ */ | 1 | /* $OpenBSD: p_lib.c,v 1.21 2018/04/14 07:09:21 tb Exp $ */ |
| 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * | 4 | * |
| @@ -229,11 +229,8 @@ pkey_set_type(EVP_PKEY *pkey, int type, const char *str, int len) | |||
| 229 | if ((type == pkey->save_type) && pkey->ameth) | 229 | if ((type == pkey->save_type) && pkey->ameth) |
| 230 | return 1; | 230 | return 1; |
| 231 | #ifndef OPENSSL_NO_ENGINE | 231 | #ifndef OPENSSL_NO_ENGINE |
| 232 | /* If we have an ENGINE release it */ | 232 | ENGINE_finish(pkey->engine); |
| 233 | if (pkey->engine) { | 233 | pkey->engine = NULL; |
| 234 | ENGINE_finish(pkey->engine); | ||
| 235 | pkey->engine = NULL; | ||
| 236 | } | ||
| 237 | #endif | 234 | #endif |
| 238 | } | 235 | } |
| 239 | if (str) | 236 | if (str) |
| @@ -241,7 +238,7 @@ pkey_set_type(EVP_PKEY *pkey, int type, const char *str, int len) | |||
| 241 | else | 238 | else |
| 242 | ameth = EVP_PKEY_asn1_find(&e, type); | 239 | ameth = EVP_PKEY_asn1_find(&e, type); |
| 243 | #ifndef OPENSSL_NO_ENGINE | 240 | #ifndef OPENSSL_NO_ENGINE |
| 244 | if (!pkey && e) | 241 | if (pkey == NULL) |
| 245 | ENGINE_finish(e); | 242 | ENGINE_finish(e); |
| 246 | #endif | 243 | #endif |
| 247 | if (!ameth) { | 244 | if (!ameth) { |
| @@ -426,8 +423,7 @@ EVP_PKEY_type(int type) | |||
| 426 | else | 423 | else |
| 427 | ret = NID_undef; | 424 | ret = NID_undef; |
| 428 | #ifndef OPENSSL_NO_ENGINE | 425 | #ifndef OPENSSL_NO_ENGINE |
| 429 | if (e) | 426 | ENGINE_finish(e); |
| 430 | ENGINE_finish(e); | ||
| 431 | #endif | 427 | #endif |
| 432 | return ret; | 428 | return ret; |
| 433 | } | 429 | } |
| @@ -470,10 +466,8 @@ EVP_PKEY_free_it(EVP_PKEY *x) | |||
| 470 | x->pkey.ptr = NULL; | 466 | x->pkey.ptr = NULL; |
| 471 | } | 467 | } |
| 472 | #ifndef OPENSSL_NO_ENGINE | 468 | #ifndef OPENSSL_NO_ENGINE |
| 473 | if (x->engine) { | 469 | ENGINE_finish(x->engine); |
| 474 | ENGINE_finish(x->engine); | 470 | x->engine = NULL; |
| 475 | x->engine = NULL; | ||
| 476 | } | ||
| 477 | #endif | 471 | #endif |
| 478 | } | 472 | } |
| 479 | 473 | ||
