From: Vitaly Chikunov Date: Sat, 8 Jan 2022 23:34:57 +0000 (+0300) Subject: gost_prov: Avoid access to unallocated memory X-Git-Tag: v3.0.1~9 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=eea1e27c2b49d7604df939aeefaa7f45a5519fc8;p=openssl-gost%2Fengine.git gost_prov: Avoid access to unallocated memory This should fix Coverity warning: *** CID 345245: (UNINIT) /gost_prov.c: 71 in provider_ctx_new() 65 && populate_gost_engine(ctx->e)) { 66 ctx->core_handle = core; 67 68 /* Ugly hack */ 69 err_handle = ctx->proverr_handle; 70 } else { >>> CID 345245: (UNINIT) >>> Using uninitialized value "ctx->e" when calling "provider_ctx_free". 71 provider_ctx_free(ctx); 72 ctx = NULL; 73 } 74 return ctx; 75 } Signed-off-by: Vitaly Chikunov Issue: #380 --- diff --git a/gost_prov.c b/gost_prov.c index b4de15f..3d23765 100644 --- a/gost_prov.c +++ b/gost_prov.c @@ -58,7 +58,7 @@ static PROV_CTX *provider_ctx_new(const OSSL_CORE_HANDLE *core, { PROV_CTX *ctx; - if ((ctx = malloc(sizeof(*ctx))) != NULL + if ((ctx = OPENSSL_zalloc(sizeof(*ctx))) != NULL && (ctx->proverr_handle = proverr_new_handle(core, in)) != NULL && (ctx->libctx = OSSL_LIB_CTX_new()) != NULL && (ctx->e = ENGINE_new()) != NULL