mirror of
https://github.com/openssl/openssl.git
synced 2025-01-30 14:01:55 +08:00
Fix a memory leak in the afalg engine
Fixes: #16743 Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/16744)
This commit is contained in:
parent
59cd0bc136
commit
6f6a5e0c7c
@ -683,11 +683,8 @@ static int afalg_cipher_cleanup(EVP_CIPHER_CTX *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
actx = (afalg_ctx *) EVP_CIPHER_CTX_get_cipher_data(ctx);
|
actx = (afalg_ctx *) EVP_CIPHER_CTX_get_cipher_data(ctx);
|
||||||
if (actx == NULL || actx->init_done != MAGIC_INIT_NUM) {
|
if (actx == NULL || actx->init_done != MAGIC_INIT_NUM)
|
||||||
ALG_WARN("%s afalg ctx passed\n",
|
return 1;
|
||||||
ctx == NULL ? "NULL" : "Uninitialised");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
close(actx->sfd);
|
close(actx->sfd);
|
||||||
close(actx->bfd);
|
close(actx->bfd);
|
||||||
|
@ -24,26 +24,7 @@
|
|||||||
|
|
||||||
#ifndef OPENSSL_NO_ENGINE
|
#ifndef OPENSSL_NO_ENGINE
|
||||||
static ENGINE *e;
|
static ENGINE *e;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_AFALGENG
|
|
||||||
# include <linux/version.h>
|
|
||||||
# define K_MAJ 4
|
|
||||||
# define K_MIN1 1
|
|
||||||
# define K_MIN2 0
|
|
||||||
# if LINUX_VERSION_CODE < KERNEL_VERSION(K_MAJ, K_MIN1, K_MIN2)
|
|
||||||
/*
|
|
||||||
* If we get here then it looks like there is a mismatch between the linux
|
|
||||||
* headers and the actual kernel version, so we have tried to compile with
|
|
||||||
* afalg support, but then skipped it in e_afalg.c. As far as this test is
|
|
||||||
* concerned we behave as if we had been configured without support
|
|
||||||
*/
|
|
||||||
# define OPENSSL_NO_AFALGENG
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_AFALGENG
|
|
||||||
static int test_afalg_aes_cbc(int keysize_idx)
|
static int test_afalg_aes_cbc(int keysize_idx)
|
||||||
{
|
{
|
||||||
EVP_CIPHER_CTX *ctx;
|
EVP_CIPHER_CTX *ctx;
|
||||||
@ -127,9 +108,25 @@ static int test_afalg_aes_cbc(int keysize_idx)
|
|||||||
EVP_CIPHER_CTX_free(ctx);
|
EVP_CIPHER_CTX_free(ctx);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef OPENSSL_NO_ENGINE
|
static int test_pr16743(void)
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
const EVP_CIPHER * cipher;
|
||||||
|
EVP_CIPHER_CTX *ctx;
|
||||||
|
|
||||||
|
if (!TEST_true(ENGINE_init(e)))
|
||||||
|
return 0;
|
||||||
|
cipher = ENGINE_get_cipher(e, NID_aes_128_cbc);
|
||||||
|
ctx = EVP_CIPHER_CTX_new();
|
||||||
|
if (cipher != NULL && ctx != NULL)
|
||||||
|
ret = EVP_EncryptInit_ex(ctx, cipher, e, NULL, NULL);
|
||||||
|
TEST_true(ret);
|
||||||
|
EVP_CIPHER_CTX_free(ctx);
|
||||||
|
ENGINE_finish(e);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int global_init(void)
|
int global_init(void)
|
||||||
{
|
{
|
||||||
ENGINE_load_builtin_engines();
|
ENGINE_load_builtin_engines();
|
||||||
@ -147,9 +144,8 @@ int setup_tests(void)
|
|||||||
/* Probably a platform env issue, not a test failure. */
|
/* Probably a platform env issue, not a test failure. */
|
||||||
TEST_info("Can't load AFALG engine");
|
TEST_info("Can't load AFALG engine");
|
||||||
} else {
|
} else {
|
||||||
# ifndef OPENSSL_NO_AFALGENG
|
|
||||||
ADD_ALL_TESTS(test_afalg_aes_cbc, 3);
|
ADD_ALL_TESTS(test_afalg_aes_cbc, 3);
|
||||||
# endif
|
ADD_TEST(test_pr16743);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user