Skip to content

Commit

Permalink
Fix potential NULL pointer dereference
Browse files Browse the repository at this point in the history
In EC key generation, if allocation of struct ec_gen_ctx fails, values
provided by parameters are copied into the context at represented by a NULL
pointer.  To fix this, prevent copy if allocation fails.

Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>

Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #20055)

(cherry picked from commit 235ef96)
  • Loading branch information
juergenchrist authored and t8m committed Jan 17, 2023
1 parent 16129bf commit 05040e9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions providers/implementations/keymgmt/ec_kmgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1004,10 +1004,10 @@ static void *ec_gen_init(void *provctx, int selection,
gctx->libctx = libctx;
gctx->selection = selection;
gctx->ecdh_mode = 0;
}
if (!ec_gen_set_params(gctx, params)) {
OPENSSL_free(gctx);
gctx = NULL;
if (!ec_gen_set_params(gctx, params)) {
OPENSSL_free(gctx);
gctx = NULL;
}
}
return gctx;
}
Expand Down

0 comments on commit 05040e9

Please sign in to comment.