Skip to content

Commit

Permalink
ec_kmgmt.c: check the return of BN_CTX_get() in time.
Browse files Browse the repository at this point in the history
If x and y are all NULL, then it is unnecessary to do subsequent operations.

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #19905)

(cherry picked from commit 467b049)
  • Loading branch information
x2018 authored and t8m committed Dec 22, 2022
1 parent 9f78288 commit 6354949
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions providers/implementations/keymgmt/ec_kmgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,16 @@ int key_to_params(const EC_KEY *eckey, OSSL_PARAM_BLD *tmpl,
goto err;
}
if (px != NULL || py != NULL) {
if (px != NULL)
if (px != NULL) {
x = BN_CTX_get(bnctx);
if (py != NULL)
if (x == NULL)
goto err;
}
if (py != NULL) {
y = BN_CTX_get(bnctx);
if (y == NULL)
goto err;
}

if (!EC_POINT_get_affine_coordinates(ecg, pub_point, x, y, bnctx))
goto err;
Expand Down

0 comments on commit 6354949

Please sign in to comment.