OpenSSL: Fix a memory leak in crypto_ec_key_parse_priv()
The OpenSSL 3.x version of crypto_ec_key_parse_priv using
OSSL_DECODER_CTX missed the call to free the context. Fix it to avoid a
memory leak.
Fixes: 4f4479ef9e
("OpenSSL: crypto_ec_key_parse_{priv,pub}() without EC_KEY API")
Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
aa1aa289cd
commit
2814dbd6db
1 changed files with 5 additions and 1 deletions
|
@ -3010,11 +3010,15 @@ struct crypto_ec_key * crypto_ec_key_parse_priv(const u8 *der, size_t der_len)
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
if (!ctx ||
|
if (!ctx ||
|
||||||
OSSL_DECODER_from_data(ctx, &der, &der_len) != 1) {
|
OSSL_DECODER_from_data(ctx, &der, &der_len) != 1) {
|
||||||
wpa_printf(MSG_INFO, "OpenSSL: Decoding EC private key (DER) failed: %s",
|
wpa_printf(MSG_INFO,
|
||||||
|
"OpenSSL: Decoding EC private key (DER) failed: %s",
|
||||||
ERR_error_string(ERR_get_error(), NULL));
|
ERR_error_string(ERR_get_error(), NULL));
|
||||||
|
if (ctx)
|
||||||
|
OSSL_DECODER_CTX_free(ctx);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OSSL_DECODER_CTX_free(ctx);
|
||||||
return (struct crypto_ec_key *) pkey;
|
return (struct crypto_ec_key *) pkey;
|
||||||
fail:
|
fail:
|
||||||
crypto_ec_key_deinit((struct crypto_ec_key *) pkey);
|
crypto_ec_key_deinit((struct crypto_ec_key *) pkey);
|
||||||
|
|
Loading…
Reference in a new issue