Fix memory leak in ecdsa_keygen_knownanswer_test
We allocate an EC_POINT with EC_POINT_new here, but in failing a
subsequent check, we don't free it, correct that.
Fixes #26779
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/26799)
(cherry picked from commit 20a2f3beba
)
This commit is contained in:
parent
b1895255b9
commit
02121df47d
1 changed files with 4 additions and 4 deletions
|
@ -256,10 +256,7 @@ static int ecdsa_keygen_knownanswer_test(EC_KEY *eckey, BN_CTX *ctx,
|
||||||
int len, ret = 0;
|
int len, ret = 0;
|
||||||
OSSL_SELF_TEST *st = NULL;
|
OSSL_SELF_TEST *st = NULL;
|
||||||
unsigned char bytes[512] = {0};
|
unsigned char bytes[512] = {0};
|
||||||
EC_POINT *pub_key2 = EC_POINT_new(eckey->group);
|
EC_POINT *pub_key2 = NULL;
|
||||||
|
|
||||||
if (pub_key2 == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
st = OSSL_SELF_TEST_new(cb, cbarg);
|
st = OSSL_SELF_TEST_new(cb, cbarg);
|
||||||
if (st == NULL)
|
if (st == NULL)
|
||||||
|
@ -268,6 +265,9 @@ static int ecdsa_keygen_knownanswer_test(EC_KEY *eckey, BN_CTX *ctx,
|
||||||
OSSL_SELF_TEST_onbegin(st, OSSL_SELF_TEST_TYPE_PCT_KAT,
|
OSSL_SELF_TEST_onbegin(st, OSSL_SELF_TEST_TYPE_PCT_KAT,
|
||||||
OSSL_SELF_TEST_DESC_PCT_ECDSA);
|
OSSL_SELF_TEST_DESC_PCT_ECDSA);
|
||||||
|
|
||||||
|
if ((pub_key2 = EC_POINT_new(eckey->group)) == NULL)
|
||||||
|
goto err;
|
||||||
|
|
||||||
/* pub_key = priv_key * G (where G is a point on the curve) */
|
/* pub_key = priv_key * G (where G is a point on the curve) */
|
||||||
if (!EC_POINT_mul(eckey->group, pub_key2, eckey->priv_key, NULL, NULL, ctx))
|
if (!EC_POINT_mul(eckey->group, pub_key2, eckey->priv_key, NULL, NULL, ctx))
|
||||||
goto err;
|
goto err;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue