From 374627ab520fca0a189d56a747abbff7e2b67bd7 Mon Sep 17 00:00:00 2001 From: Dmitry Belyavskiy Date: Mon, 7 Feb 2022 18:31:04 +0100 Subject: [PATCH] Ensure that CMAC_ACPKM_CTX_copy works with 2 non-NULL pointers - fixup Related: #387 --- gost_omac_acpkm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gost_omac_acpkm.c b/gost_omac_acpkm.c index 507ca53..8e2c4df 100644 --- a/gost_omac_acpkm.c +++ b/gost_omac_acpkm.c @@ -98,7 +98,7 @@ static void CMAC_ACPKM_CTX_free(CMAC_ACPKM_CTX *ctx) OPENSSL_free(ctx); } -int CMAC_ACPKM_CTX_copy(CMAC_ACPKM_CTX *out, const CMAC_ACPKM_CTX *in) +static int CMAC_ACPKM_CTX_copy(CMAC_ACPKM_CTX *out, const CMAC_ACPKM_CTX *in) { int bl; if (in->nlast_block == -1) @@ -375,7 +375,8 @@ static int omac_acpkm_imit_copy(EVP_MD_CTX *to, const EVP_MD_CTX *from) if ((c_to->cmac_ctx == c_from->cmac_ctx) || (c_to->cmac_ctx == NULL)) { c_to->cmac_ctx = CMAC_ACPKM_CTX_new(); } - return CMAC_ACPKM_CTX_copy(c_to->cmac_ctx, c_from->cmac_ctx); + + return (c_to->cmac_ctx) ? CMAC_ACPKM_CTX_copy(c_to->cmac_ctx, c_from->cmac_ctx) : 0; } /* Clean up imit ctx */ -- 2.39.5