X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=engines%2Fe_chil.c;h=0764c01db2415cd69713909e31959c9df20b6255;hb=4dc1aa0436fdb8af50960db676b739c8ef81f38c;hp=19d29d7e62f7fc909c318f8960843f95c0ac6244;hpb=d64070838ebba86f00fb3755df5d3e65106e1628;p=oweals%2Fopenssl.git diff --git a/engines/e_chil.c b/engines/e_chil.c index 19d29d7e62..0764c01db2 100644 --- a/engines/e_chil.c +++ b/engines/e_chil.c @@ -462,8 +462,7 @@ static HWCryptoHook_ModExpCRT_t *p_hwcrhk_ModExpCRT = NULL; static const char *HWCRHK_LIBNAME = NULL; static void free_HWCRHK_LIBNAME(void) { - if (HWCRHK_LIBNAME) - OPENSSL_free((void *)HWCRHK_LIBNAME); + OPENSSL_free(HWCRHK_LIBNAME); HWCRHK_LIBNAME = NULL; } @@ -556,26 +555,19 @@ static int hwcrhk_init(ENGINE *e) HWCRHKerr(HWCRHK_F_HWCRHK_INIT, HWCRHK_R_DSO_FAILURE); goto err; } - if (!(p1 = (HWCryptoHook_Init_t *) - DSO_bind_func(hwcrhk_dso, n_hwcrhk_Init)) || - !(p2 = (HWCryptoHook_Finish_t *) - DSO_bind_func(hwcrhk_dso, n_hwcrhk_Finish)) || - !(p3 = (HWCryptoHook_ModExp_t *) - DSO_bind_func(hwcrhk_dso, n_hwcrhk_ModExp)) || + +#define BINDIT(t, name) (t *)DSO_bind_func(hwcrhk_dso, name) + if ((p1 = BINDIT(HWCryptoHook_Init_t, n_hwcrhk_Init)) == NULL + || (p2 = BINDIT(HWCryptoHook_Finish_t, n_hwcrhk_Finish)) == NULL + || (p3 = BINDIT(HWCryptoHook_ModExp_t, n_hwcrhk_ModExp)) == NULL # ifndef OPENSSL_NO_RSA - !(p4 = (HWCryptoHook_RSA_t *) - DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSA)) || - !(p5 = (HWCryptoHook_RSALoadKey_t *) - DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSALoadKey)) || - !(p6 = (HWCryptoHook_RSAGetPublicKey_t *) - DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSAGetPublicKey)) || - !(p7 = (HWCryptoHook_RSAUnloadKey_t *) - DSO_bind_func(hwcrhk_dso, n_hwcrhk_RSAUnloadKey)) || + || (p4 = BINDIT(HWCryptoHook_RSA_t, n_hwcrhk_RSA)) == NULL + || (p5 = BINDIT(HWCryptoHook_RSALoadKey_t, n_hwcrhk_RSALoadKey)) == NULL + || (p6 = BINDIT(HWCryptoHook_RSAGetPublicKey_t, n_hwcrhk_RSAGetPublicKey)) == NULL + || (p7 = BINDIT(HWCryptoHook_RSAUnloadKey_t, n_hwcrhk_RSAUnloadKey)) == NULL # endif - !(p8 = (HWCryptoHook_RandomBytes_t *) - DSO_bind_func(hwcrhk_dso, n_hwcrhk_RandomBytes)) || - !(p9 = (HWCryptoHook_ModExpCRT_t *) - DSO_bind_func(hwcrhk_dso, n_hwcrhk_ModExpCRT))) { + || (p8 = BINDIT(HWCryptoHook_RandomBytes_t, n_hwcrhk_RandomBytes)) == NULL + || (p9 = BINDIT(HWCryptoHook_ModExpCRT_t, n_hwcrhk_ModExpCRT)) == NULL) { HWCRHKerr(HWCRHK_F_HWCRHK_INIT, HWCRHK_R_DSO_FAILURE); goto err; } @@ -623,8 +615,7 @@ static int hwcrhk_init(ENGINE *e) # endif return 1; err: - if (hwcrhk_dso) - DSO_free(hwcrhk_dso); + DSO_free(hwcrhk_dso); hwcrhk_dso = NULL; p_hwcrhk_Init = NULL; p_hwcrhk_Finish = NULL; @@ -656,8 +647,7 @@ static int hwcrhk_finish(ENGINE *e) goto err; } err: - if (logstream) - BIO_free(logstream); + BIO_free(logstream); hwcrhk_dso = NULL; p_hwcrhk_Init = NULL; p_hwcrhk_Finish = NULL; @@ -693,10 +683,8 @@ static int hwcrhk_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void)) BIO *bio = (BIO *)p; CRYPTO_w_lock(CRYPTO_LOCK_ENGINE); - if (logstream) { - BIO_free(logstream); - logstream = NULL; - } + BIO_free(logstream); + logstream = NULL; if (CRYPTO_add(&bio->references, 1, CRYPTO_LOCK_BIO) > 1) logstream = bio; else @@ -791,7 +779,7 @@ static EVP_PKEY *hwcrhk_load_privkey(ENGINE *eng, const char *key_id, goto err; } # ifndef OPENSSL_NO_RSA - hptr = OPENSSL_malloc(sizeof(HWCryptoHook_RSAKeyHandle)); + hptr = OPENSSL_malloc(sizeof(*hptr)); if (!hptr) { HWCRHKerr(HWCRHK_F_HWCRHK_LOAD_PRIVKEY, ERR_R_MALLOC_FAILURE); goto err; @@ -890,8 +878,7 @@ static EVP_PKEY *hwcrhk_load_pubkey(ENGINE *eng, const char *key_id, return res; err: - if (res) - EVP_PKEY_free(res); + EVP_PKEY_free(res); return NULL; }