mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-13 03:40:05 +01:00
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.
This commit is contained in:
committed by
Milan Broz
parent
2fc8b6a306
commit
443a8b806f
@@ -95,7 +95,8 @@ int crypt_hash_init(struct crypt_hash **ctx, const char *name)
|
|||||||
return -EINVAL;
|
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);
|
free(h);
|
||||||
return -EINVAL;
|
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)
|
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 -EINVAL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user