From d4e8033fe06a5cd9b2cd22c3cdd485af1a76195f Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Thu, 20 Oct 2016 08:22:38 +0200 Subject: [PATCH] Fix error path after conversion to OpenSSL 1.1.0. --- lib/crypto_backend/crypto_openssl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/crypto_backend/crypto_openssl.c b/lib/crypto_backend/crypto_openssl.c index 256d8c20..c19fd9bb 100644 --- a/lib/crypto_backend/crypto_openssl.c +++ b/lib/crypto_backend/crypto_openssl.c @@ -134,11 +134,13 @@ int crypt_hash_init(struct crypt_hash **ctx, const char *name) h->hash_id = EVP_get_digestbyname(name); if (!h->hash_id) { + EVP_MD_CTX_free(h->md); free(h); return -EINVAL; } if (EVP_DigestInit_ex(h->md, h->hash_id, NULL) != 1) { + EVP_MD_CTX_free(h->md); free(h); return -EINVAL; } @@ -218,6 +220,7 @@ int crypt_hmac_init(struct crypt_hmac **ctx, const char *name, h->hash_id = EVP_get_digestbyname(name); if (!h->hash_id) { + HMAC_CTX_free(h->md); free(h); return -EINVAL; } @@ -298,7 +301,7 @@ int crypt_pbkdf(const char *kdf, const char *hash, return -EINVAL; if (!PKCS5_PBKDF2_HMAC(password, (int)password_length, - (unsigned char *)salt, (int)salt_length, + (const unsigned char *)salt, (int)salt_length, (int)iterations, hash_id, (int)key_length, (unsigned char *)key)) return -EINVAL;