From c562788068ed9186807aa2c857954f925dd9644d Mon Sep 17 00:00:00 2001 From: Mateusz Starzyk Date: Mon, 2 Aug 2021 11:49:58 +0200 Subject: [PATCH] Fix local buffer allocation conditions. Signed-off-by: Mateusz Starzyk --- library/ccm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/library/ccm.c b/library/ccm.c index af26de8d4f..20e9414acc 100644 --- a/library/ccm.c +++ b/library/ccm.c @@ -351,8 +351,9 @@ int mbedtls_ccm_update( mbedtls_ccm_context *ctx, } /* Local output is used for decryption only. */ - if( ctx->mode == MBEDTLS_CCM_DECRYPT || \ - ctx->mode == MBEDTLS_CCM_STAR_DECRYPT ) + if( local_output_len > 0 && \ + ( ctx->mode == MBEDTLS_CCM_DECRYPT || \ + ctx->mode == MBEDTLS_CCM_STAR_DECRYPT ) ) { local_output = mbedtls_calloc( local_output_len, sizeof( *local_output) ); if( local_output == NULL )