From: Matt Caswell Date: Wed, 4 Oct 2023 15:32:31 +0000 (+0100) Subject: Fix coverity alert on use of uninitialised data X-Git-Tag: openssl-3.2.0-beta1~120 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=31fc8a83bc9aa435ae40c3eff713ced441eaa011;p=thirdparty%2Fopenssl.git Fix coverity alert on use of uninitialised data The function `ossl_blake2b_param_init` should initialise only, and not read the data it is initialising Reviewed-by: Richard Levitte Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/22282) --- diff --git a/providers/implementations/digests/blake2_prov.c b/providers/implementations/digests/blake2_prov.c index 298bc66de65..34bbd7ed37d 100644 --- a/providers/implementations/digests/blake2_prov.c +++ b/providers/implementations/digests/blake2_prov.c @@ -23,8 +23,11 @@ static int ossl_blake2s256_init(void *ctx) static int ossl_blake2b512_init(void *ctx) { struct blake2b_md_data_st *mdctx = ctx; + uint8_t digest_length = mdctx->params.digest_length; ossl_blake2b_param_init(&mdctx->params); + if (digest_length != 0) + mdctx->params.digest_length = digest_length; return ossl_blake2b_init(&mdctx->ctx, &mdctx->params); } diff --git a/providers/implementations/digests/blake2b_prov.c b/providers/implementations/digests/blake2b_prov.c index 8125dab41f4..0e3e894a43b 100644 --- a/providers/implementations/digests/blake2b_prov.c +++ b/providers/implementations/digests/blake2b_prov.c @@ -121,8 +121,7 @@ static void blake2b_init_param(BLAKE2B_CTX *S, const BLAKE2B_PARAM *P) /* Initialize the parameter block with default values */ void ossl_blake2b_param_init(BLAKE2B_PARAM *P) { - if (P->digest_length == 0) - P->digest_length = BLAKE2B_DIGEST_LENGTH; + P->digest_length = BLAKE2B_DIGEST_LENGTH; P->key_length = 0; P->fanout = 1; P->depth = 1;