From 7260709e9ef155c8b3fccaa32e8ba496a3059905 Mon Sep 17 00:00:00 2001 From: slontis Date: Thu, 23 Jun 2022 13:10:55 +1000 Subject: kdf objects missing a return if malloc fails. I have searched through all references of ERR_R_MALLOC_FAILURE for any other instances.. Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale Reviewed-by: Hugo Landau (Merged from https://github.com/openssl/openssl/pull/18638) --- providers/implementations/kdfs/tls1_prf.c | 4 +++- providers/implementations/kdfs/x942kdf.c | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'providers') diff --git a/providers/implementations/kdfs/tls1_prf.c b/providers/implementations/kdfs/tls1_prf.c index 96eab4ea41..fd46283d3a 100644 --- a/providers/implementations/kdfs/tls1_prf.c +++ b/providers/implementations/kdfs/tls1_prf.c @@ -103,8 +103,10 @@ static void *kdf_tls1_prf_new(void *provctx) if (!ossl_prov_is_running()) return NULL; - if ((ctx = OPENSSL_zalloc(sizeof(*ctx))) == NULL) + if ((ctx = OPENSSL_zalloc(sizeof(*ctx))) == NULL) { ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE); + return NULL; + } ctx->provctx = provctx; return ctx; } diff --git a/providers/implementations/kdfs/x942kdf.c b/providers/implementations/kdfs/x942kdf.c index 487c3295f2..51b2ebf26b 100644 --- a/providers/implementations/kdfs/x942kdf.c +++ b/providers/implementations/kdfs/x942kdf.c @@ -333,10 +333,12 @@ static void *x942kdf_new(void *provctx) KDF_X942 *ctx; if (!ossl_prov_is_running()) - return 0; + return NULL; - if ((ctx = OPENSSL_zalloc(sizeof(*ctx))) == NULL) + if ((ctx = OPENSSL_zalloc(sizeof(*ctx))) == NULL) { ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE); + return NULL; + } ctx->provctx = provctx; ctx->use_keybits = 1; return ctx; -- cgit v1.2.1