Skip to content

Commit

Permalink
gost_prov: Avoid access to unallocated memory
Browse files Browse the repository at this point in the history
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 <[email protected]>
Issue: gost-engine#380
  • Loading branch information
vt-alt committed Jan 8, 2022
1 parent 593840e commit f5a3951
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gost_prov.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f5a3951

Please sign in to comment.