diff options
author | Matt Caswell <matt@openssl.org> | 2019-03-26 14:42:14 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2019-03-27 10:26:52 +0000 |
commit | 183f52e29af27285ea4ed7c947b71c83618f8702 (patch) | |
tree | ba181ac2122064758f9b7a0bab743acdbf13e5ab /crypto/evp/e_aria.c | |
parent | a8274ea351988aa754cb9983b27d7059613ee11e (diff) |
Fix a memory leak in ARIA GCM
Fixes #8567
Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/8586)
Diffstat (limited to 'crypto/evp/e_aria.c')
-rw-r--r-- | crypto/evp/e_aria.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/crypto/evp/e_aria.c b/crypto/evp/e_aria.c index 1d4ac2a252..882849486e 100644 --- a/crypto/evp/e_aria.c +++ b/crypto/evp/e_aria.c @@ -486,6 +486,16 @@ static int aria_gcm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, return 0; } +static int aria_gcm_cleanup(EVP_CIPHER_CTX *ctx) +{ + EVP_ARIA_GCM_CTX *gctx = EVP_C_DATA(EVP_ARIA_GCM_CTX, ctx); + + if (gctx->iv != EVP_CIPHER_CTX_iv_noconst(ctx)) + OPENSSL_free(gctx->iv); + + return 1; +} + static int aria_ccm_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, const unsigned char *iv, int enc) { @@ -727,6 +737,8 @@ static int aria_ccm_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, } } +#define aria_ccm_cleanup NULL + #define ARIA_AUTH_FLAGS (EVP_CIPH_FLAG_DEFAULT_ASN1 \ | EVP_CIPH_CUSTOM_IV | EVP_CIPH_FLAG_CUSTOM_CIPHER \ | EVP_CIPH_ALWAYS_CALL_INIT | EVP_CIPH_CTRL_INIT \ @@ -739,7 +751,7 @@ static const EVP_CIPHER aria_##keylen##_##mode = { \ ARIA_AUTH_FLAGS|EVP_CIPH_##MODE##_MODE, \ aria_##mode##_init_key, \ aria_##mode##_cipher, \ - NULL, \ + aria_##mode##_cleanup, \ sizeof(EVP_ARIA_##MODE##_CTX), \ NULL,NULL,aria_##mode##_ctrl,NULL }; \ const EVP_CIPHER *EVP_aria_##keylen##_##mode(void) \ |