libfreerdp-core: fix tsg crash on disconnect
This commit is contained in:
parent
94494511cc
commit
46724b0c75
@ -337,6 +337,7 @@ static int transport_bio_simple_uninit(BIO* bio)
|
||||
{
|
||||
if (bio->init)
|
||||
{
|
||||
_shutdown(ptr->socket, SD_BOTH);
|
||||
closesocket(ptr->socket);
|
||||
ptr->socket = 0;
|
||||
}
|
||||
@ -1123,19 +1124,6 @@ BOOL freerdp_tcp_connect(rdpTcp* tcp, const char* hostname, int port, int timeou
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL freerdp_tcp_disconnect(rdpTcp* tcp)
|
||||
{
|
||||
if (tcp->sockfd != -1)
|
||||
{
|
||||
shutdown(tcp->sockfd, SHUT_RDWR);
|
||||
close(tcp->sockfd);
|
||||
|
||||
tcp->sockfd = -1;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL freerdp_tcp_set_blocking_mode(rdpTcp* tcp, BOOL blocking)
|
||||
{
|
||||
return BIO_set_nonblock(tcp->socketBio, blocking ? 0 : 1) ? TRUE : FALSE;
|
||||
|
@ -70,7 +70,6 @@ struct rdp_tcp
|
||||
};
|
||||
|
||||
BOOL freerdp_tcp_connect(rdpTcp* tcp, const char* hostname, int port, int timeout);
|
||||
BOOL freerdp_tcp_disconnect(rdpTcp* tcp);
|
||||
int freerdp_tcp_read(rdpTcp* tcp, BYTE* data, int length);
|
||||
int freerdp_tcp_write(rdpTcp* tcp, BYTE* data, int length);
|
||||
int freerdp_tcp_wait_read(rdpTcp* tcp, DWORD dwMilliSeconds);
|
||||
|
@ -100,36 +100,44 @@ BOOL transport_disconnect(rdpTransport* transport)
|
||||
|
||||
transport_stop(transport);
|
||||
|
||||
if (transport->TlsIn)
|
||||
tls_free(transport->TlsIn);
|
||||
if (transport->tsg)
|
||||
{
|
||||
if (transport->TsgTls)
|
||||
{
|
||||
tls_free(transport->TsgTls);
|
||||
transport->TsgTls = NULL;
|
||||
}
|
||||
|
||||
if (transport->TlsOut != transport->TlsIn)
|
||||
tls_free(transport->TlsOut);
|
||||
tsg_free(transport->tsg);
|
||||
transport->tsg = NULL;
|
||||
|
||||
if (transport->TlsIn)
|
||||
tls_free(transport->TlsIn);
|
||||
|
||||
if (transport->TcpIn)
|
||||
freerdp_tcp_free(transport->TcpIn);
|
||||
|
||||
if (transport->TlsOut)
|
||||
tls_free(transport->TlsOut);
|
||||
|
||||
if (transport->TcpOut)
|
||||
freerdp_tcp_free(transport->TcpOut);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (transport->TlsIn)
|
||||
tls_free(transport->TlsIn);
|
||||
|
||||
if (transport->TcpIn)
|
||||
freerdp_tcp_free(transport->TcpIn);
|
||||
}
|
||||
|
||||
transport->TlsIn = NULL;
|
||||
transport->TlsOut = NULL;
|
||||
|
||||
if (transport->tsg)
|
||||
{
|
||||
tsg_free(transport->tsg);
|
||||
transport->tsg = NULL;
|
||||
}
|
||||
|
||||
if (transport->TcpOut && (transport->TcpOut != transport->TcpIn)) {
|
||||
freerdp_tcp_disconnect(transport->TcpOut);
|
||||
freerdp_tcp_free(transport->TcpOut);
|
||||
}
|
||||
|
||||
transport->TcpIn = NULL;
|
||||
transport->TcpOut = NULL;
|
||||
|
||||
if (transport->TsgTls)
|
||||
{
|
||||
tls_free(transport->TsgTls);
|
||||
transport->TsgTls = NULL;
|
||||
}
|
||||
|
||||
freerdp_tcp_disconnect(transport->TcpIn);
|
||||
|
||||
transport->layer = TRANSPORT_LAYER_TCP;
|
||||
|
||||
return status;
|
||||
@ -1168,5 +1176,6 @@ void transport_free(rdpTransport* transport)
|
||||
CloseHandle(transport->connectedEvent);
|
||||
DeleteCriticalSection(&(transport->ReadLock));
|
||||
DeleteCriticalSection(&(transport->WriteLock));
|
||||
|
||||
free(transport);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user