libtls: Fix double-free for untrusted peer certificates
`public` is returned, but previously only if a trusted key was found.
We obviously don't want to return untrusted keys and since the reference
was correctly destroyed after determining the key type, this later caused
a double-free.
Fixes: 63fd718915 ("libtls: call create_public_enumerator() with key_type")
This commit is contained in:
@@ -183,11 +183,11 @@ public_key_t *tls_find_public_key(auth_cfg_t *peer_auth, identification_t *id)
|
|||||||
cert = peer_auth->get(peer_auth, AUTH_HELPER_SUBJECT_CERT);
|
cert = peer_auth->get(peer_auth, AUTH_HELPER_SUBJECT_CERT);
|
||||||
if (cert)
|
if (cert)
|
||||||
{
|
{
|
||||||
public = cert->get_public_key(cert);
|
current = cert->get_public_key(cert);
|
||||||
if (public)
|
if (current)
|
||||||
{
|
{
|
||||||
key_type = public->get_type(public);
|
key_type = current->get_type(current);
|
||||||
public->destroy(public);
|
current->destroy(current);
|
||||||
}
|
}
|
||||||
enumerator = lib->credmgr->create_public_enumerator(lib->credmgr,
|
enumerator = lib->credmgr->create_public_enumerator(lib->credmgr,
|
||||||
key_type, id, peer_auth, TRUE);
|
key_type, id, peer_auth, TRUE);
|
||||||
|
|||||||
Reference in New Issue
Block a user