mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
fix TLS free logic, fixing double free in issue #531
This commit is contained in:
@@ -92,8 +92,11 @@ boolean transport_connect_tls(rdpTransport* transport)
|
||||
transport->layer = TRANSPORT_LAYER_TLS;
|
||||
transport->tls->sockfd = transport->tcp->sockfd;
|
||||
|
||||
if (tls_connect(transport->tls) != true)
|
||||
if (tls_connect(transport->tls) != true) {
|
||||
tls_free(transport->tls);
|
||||
transport->tls = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -109,8 +112,11 @@ boolean transport_connect_nla(rdpTransport* transport)
|
||||
transport->layer = TRANSPORT_LAYER_TLS;
|
||||
transport->tls->sockfd = transport->tcp->sockfd;
|
||||
|
||||
if (tls_connect(transport->tls) != true)
|
||||
if (tls_connect(transport->tls) != true) {
|
||||
tls_free(transport->tls);
|
||||
transport->tls = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Network Level Authentication */
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ static void tls_free_certificate(CryptoCert cert)
|
||||
xfree(cert);
|
||||
}
|
||||
|
||||
|
||||
boolean tls_connect(rdpTls* tls)
|
||||
{
|
||||
CryptoCert cert;
|
||||
@@ -80,15 +81,12 @@ boolean tls_connect(rdpTls* tls)
|
||||
|
||||
if (tls->ssl == NULL)
|
||||
{
|
||||
SSL_CTX_free(tls->ctx);
|
||||
printf("SSL_new failed\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (SSL_set_fd(tls->ssl, tls->sockfd) < 1)
|
||||
{
|
||||
SSL_free(tls->ssl);
|
||||
SSL_CTX_free(tls->ctx);
|
||||
printf("SSL_set_fd failed\n");
|
||||
return false;
|
||||
}
|
||||
@@ -99,8 +97,6 @@ boolean tls_connect(rdpTls* tls)
|
||||
{
|
||||
if (tls_print_error("SSL_connect", tls->ssl, connection_status))
|
||||
{
|
||||
SSL_free(tls->ssl);
|
||||
SSL_CTX_free(tls->ctx);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user