mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-01-19 11:24:05 -05:00
DPP: Fix a memory leak in key pair generation
ec_params needs to be free within dpp_gen_keypair() to avoid leaking the allocated memory. Signed-off-by: Jouni Malinen <jouni@codeaurora.org>
This commit is contained in:
parent
7153540c39
commit
7a9ddba6f5
@ -1135,7 +1135,7 @@ static void dpp_debug_print_key(const char *title, EVP_PKEY *key)
|
|||||||
static EVP_PKEY * dpp_gen_keypair(const struct dpp_curve_params *curve)
|
static EVP_PKEY * dpp_gen_keypair(const struct dpp_curve_params *curve)
|
||||||
{
|
{
|
||||||
EVP_PKEY_CTX *kctx = NULL;
|
EVP_PKEY_CTX *kctx = NULL;
|
||||||
EC_KEY *ec_params;
|
EC_KEY *ec_params = NULL;
|
||||||
EVP_PKEY *params = NULL, *key = NULL;
|
EVP_PKEY *params = NULL, *key = NULL;
|
||||||
int nid;
|
int nid;
|
||||||
|
|
||||||
@ -1166,19 +1166,18 @@ static EVP_PKEY * dpp_gen_keypair(const struct dpp_curve_params *curve)
|
|||||||
EVP_PKEY_keygen_init(kctx) != 1 ||
|
EVP_PKEY_keygen_init(kctx) != 1 ||
|
||||||
EVP_PKEY_keygen(kctx, &key) != 1) {
|
EVP_PKEY_keygen(kctx, &key) != 1) {
|
||||||
wpa_printf(MSG_ERROR, "DPP: Failed to generate EC key");
|
wpa_printf(MSG_ERROR, "DPP: Failed to generate EC key");
|
||||||
|
key = NULL;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wpa_debug_show_keys)
|
if (wpa_debug_show_keys)
|
||||||
dpp_debug_print_key("Own generated key", key);
|
dpp_debug_print_key("Own generated key", key);
|
||||||
|
|
||||||
|
fail:
|
||||||
|
EC_KEY_free(ec_params);
|
||||||
EVP_PKEY_free(params);
|
EVP_PKEY_free(params);
|
||||||
EVP_PKEY_CTX_free(kctx);
|
EVP_PKEY_CTX_free(kctx);
|
||||||
return key;
|
return key;
|
||||||
fail:
|
|
||||||
EVP_PKEY_CTX_free(kctx);
|
|
||||||
EVP_PKEY_free(params);
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user