mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-01-03 10:32:33 +01:00
eap-tls: Fix potential memory leak
client-cert might be leaked if ClientKey loading fails
This commit is contained in:
parent
f7df7939e6
commit
2b2b6185e4
@ -366,7 +366,7 @@ static bool eap_tls_settings_load(struct eap_state *eap,
|
|||||||
client_cert = eap_tls_load_client_cert(settings, value,
|
client_cert = eap_tls_load_client_cert(settings, value,
|
||||||
passphrase, NULL);
|
passphrase, NULL);
|
||||||
if (!client_cert)
|
if (!client_cert)
|
||||||
goto load_error;
|
goto bad_client_cert;
|
||||||
}
|
}
|
||||||
|
|
||||||
l_free(value);
|
l_free(value);
|
||||||
@ -377,7 +377,7 @@ static bool eap_tls_settings_load(struct eap_state *eap,
|
|||||||
client_key = eap_tls_load_priv_key(settings, value,
|
client_key = eap_tls_load_priv_key(settings, value,
|
||||||
passphrase, NULL);
|
passphrase, NULL);
|
||||||
if (!client_key)
|
if (!client_key)
|
||||||
goto load_error;
|
goto bad_client_key;
|
||||||
}
|
}
|
||||||
|
|
||||||
l_free(value);
|
l_free(value);
|
||||||
@ -390,15 +390,17 @@ static bool eap_tls_settings_load(struct eap_state *eap,
|
|||||||
&client_cert,
|
&client_cert,
|
||||||
&client_key, NULL) ||
|
&client_key, NULL) ||
|
||||||
!client_cert || !client_key)) {
|
!client_cert || !client_key)) {
|
||||||
l_certchain_free(client_cert);
|
goto bad_bundle;
|
||||||
l_key_free(client_key);
|
|
||||||
goto load_error;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
eap_tls_common_set_keys(eap, client_cert, client_key);
|
eap_tls_common_set_keys(eap, client_cert, client_key);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
load_error:
|
bad_bundle:
|
||||||
|
l_key_free(client_key);
|
||||||
|
bad_client_key:
|
||||||
|
l_certchain_free(client_cert);
|
||||||
|
bad_client_cert:
|
||||||
eap_tls_common_state_free(eap);
|
eap_tls_common_state_free(eap);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user