From 1e7d8d439aaafdb6f133901193ac7caa07045e42 Mon Sep 17 00:00:00 2001 From: tb Date: Tue, 9 Jul 2024 16:33:10 +0000 Subject: [PATCH] Inline an instance of OPENSSL_memdup() --- lib/libcrypto/kdf/tls1_prf.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/libcrypto/kdf/tls1_prf.c b/lib/libcrypto/kdf/tls1_prf.c index a015476c34b..00cc4e8fec1 100644 --- a/lib/libcrypto/kdf/tls1_prf.c +++ b/lib/libcrypto/kdf/tls1_prf.c @@ -71,12 +71,21 @@ static int pkey_tls1_prf_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) return 0; if (kctx->sec != NULL) freezero(kctx->sec, kctx->seclen); + explicit_bzero(kctx->seed, kctx->seedlen); kctx->seedlen = 0; - kctx->sec = OPENSSL_memdup(p2, p1); - if (kctx->sec == NULL) + + kctx->sec = NULL; + kctx->seclen = 0; + + if (p1 == 0 || p2 == NULL) return 0; + + if ((kctx->sec = calloc(1, p1)) == NULL) + return 0; + memcpy(kctx->sec, p2, p1); kctx->seclen = p1; + return 1; case EVP_PKEY_CTRL_TLS_SEED: -- 2.20.1