summaryrefslogtreecommitdiffstats
path: root/providers
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2023-10-04 16:32:31 +0100
committerTomas Mraz <tomas@openssl.org>2023-10-05 19:07:55 +0200
commit31fc8a83bc9aa435ae40c3eff713ced441eaa011 (patch)
treed5dff93bb7b35fb774d4807f124f5c68048c3083 /providers
parent0f7a3b0caa33a87c900536dc1c02fa553d2193cc (diff)
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 <levitte@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/22282)
Diffstat (limited to 'providers')
-rw-r--r--providers/implementations/digests/blake2_prov.c3
-rw-r--r--providers/implementations/digests/blake2b_prov.c3
2 files changed, 4 insertions, 2 deletions
diff --git a/providers/implementations/digests/blake2_prov.c b/providers/implementations/digests/blake2_prov.c
index 298bc66de6..34bbd7ed37 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 8125dab41f..0e3e894a43 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;