From: Tomas Mraz Date: Tue, 30 Nov 2021 10:39:52 +0000 (+0100) Subject: pvkkdf: Always reset buflen after clearing the buffer X-Git-Tag: openssl-3.2.0-alpha1~3270 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a632bfaa4ee3339749f7a6a07ab4d0abee4eaaef;p=thirdparty%2Fopenssl.git 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) --- 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; }