Commit b181b0ef authored by Per x Johansson's avatar Per x Johansson Committed by Milan Broz

Fix memory leak when using openssl backend

Fixes a memory leak when using openssl backend caused by mismatched
calls to EVP_DigestInit and EVP_DigestFinal_ex.
parent 4083bb2c
......@@ -95,7 +95,8 @@ int crypt_hash_init(struct crypt_hash **ctx, const char *name)
return -EINVAL;
}
if (EVP_DigestInit(&h->md, h->hash_id) != 1) {
EVP_MD_CTX_init(&h->md);
if (EVP_DigestInit_ex(&h->md, h->hash_id, NULL) != 1) {
free(h);
return -EINVAL;
}
......@@ -107,7 +108,7 @@ int crypt_hash_init(struct crypt_hash **ctx, const char *name)
static int crypt_hash_restart(struct crypt_hash *ctx)
{
if (EVP_DigestInit(&ctx->md, ctx->hash_id) != 1)
if (EVP_DigestInit_ex(&ctx->md, ctx->hash_id, NULL) != 1)
return -EINVAL;
return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment