From a632bfaa4ee3339749f7a6a07ab4d0abee4eaaef Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Tue, 30 Nov 2021 11:39:52 +0100 Subject: [PATCH] pvkkdf: Always reset buflen after clearing the buffer Reviewed-by: Richard Levitte Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/17164) --- providers/implementations/kdfs/pvkkdf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/providers/implementations/kdfs/pvkkdf.c b/providers/implementations/kdfs/pvkkdf.c index 051c6254554..e953911c836 100644 --- a/providers/implementations/kdfs/pvkkdf.c +++ b/providers/implementations/kdfs/pvkkdf.c @@ -97,13 +97,15 @@ static int pvk_set_membuf(unsigned char **buffer, size_t *buflen, const OSSL_PARAM *p) { OPENSSL_clear_free(*buffer, *buflen); + *buffer = NULL; + *buflen = 0; + if (p->data_size == 0) { if ((*buffer = OPENSSL_malloc(1)) == NULL) { ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE); return 0; } } else if (p->data != NULL) { - *buffer = NULL; if (!OSSL_PARAM_get_octet_string(p, (void **)buffer, 0, buflen)) return 0; } -- 2.47.2