{
if (settings->Username)
{
+ free(settings->GatewayUsername);
settings->GatewayUsername = _strdup(settings->Username);
+
if (!settings->GatewayUsername)
goto out_error;
}
if (settings->Domain)
{
+ free(settings->GatewayDomain);
settings->GatewayDomain = _strdup(settings->Domain);
+
if (!settings->GatewayDomain)
goto out_error;
}
if (settings->Password)
{
+ free(settings->GatewayPassword);
settings->GatewayPassword = _strdup(settings->Password);
+
if (!settings->GatewayPassword)
goto out_error;
}
fun:ssl3_write_pending
fun:ssl3_write_bytes
}
+
+{
+ g_type_init
+ Memcheck:Leak
+ ...
+ fun:g_type_init_with_debug_flags
+}
+{
+ gobject_init_ctor
+ Memcheck:Leak
+ ...
+ fun:gobject_init_ctor
+}
+{
+ g_type_register_static
+ Memcheck:Leak
+ ...
+ fun:g_type_register_static
+}
+{
+ g_type_register_fundamental
+ Memcheck:Leak
+ ...
+ fun:g_type_register_fundamental
+}
+{
+ g_type_add_interface_static
+ Memcheck:Leak
+ ...
+ fun:g_type_add_interface_static
+}
+{
+ g_type_class_ref
+ Memcheck:Leak
+ ...
+ fun:g_type_class_ref
+}
+
+{
+ XGetDefault
+ Memcheck:Leak
+ ...
+ fun:XGetDefault
+}
BOOL http_response_parse_header_field(HttpResponse* http_response, char* name, char* value)
{
+ BOOL status = TRUE;
+
if (_stricmp(name, "Content-Length") == 0)
{
http_response->ContentLength = atoi(value);
}
else if (_stricmp(name, "WWW-Authenticate") == 0)
{
- char* separator;
- char* authScheme, *authValue;
+ char* separator = NULL;
+ char* authScheme = NULL;
+ char* authValue = NULL;
+
separator = strchr(value, ' ');
- if (separator != NULL)
+ if (separator)
{
/* WWW-Authenticate: Basic realm=""
* WWW-Authenticate: NTLM base64token
authValue = NULL;
}
- return ListDictionary_Add(http_response->Authenticates, authScheme, authValue);
+ status = ListDictionary_Add(http_response->Authenticates, authScheme, authValue);
+
+ free(authScheme);
}
- return TRUE;
+ return status;
}
BOOL http_response_parse_header(HttpResponse* http_response)
nbytes = 0;
length = 10000;
content = NULL;
+
buffer = calloc(length, 1);
if (!buffer)
HttpResponse* http_response_new()
{
- HttpResponse* ret = (HttpResponse*)calloc(1, sizeof(HttpResponse));
+ HttpResponse* ret = (HttpResponse*) calloc(1, sizeof(HttpResponse));
if (!ret)
return NULL;
ret->Authenticates = ListDictionary_New(FALSE);
+
ListDictionary_KeyObject(ret->Authenticates)->fnObjectEquals = strings_equals_nocase;
ListDictionary_KeyObject(ret->Authenticates)->fnObjectFree = string_free;
+
ListDictionary_ValueObject(ret->Authenticates)->fnObjectEquals = strings_equals_nocase;
ListDictionary_ValueObject(ret->Authenticates)->fnObjectFree = string_free;
+
return ret;
}
free(http_response->lines);
free(http_response->ReasonPhrase);
+
ListDictionary_Free(http_response->Authenticates);
if (http_response->ContentLength > 0)
int rpc_ncacn_http_recv_out_channel_response(rdpRpc* rpc)
{
int ntlm_token_length = 0;
- BYTE* ntlm_token_data;
+ BYTE* ntlm_token_data = NULL;
HttpResponse* http_response;
rdpNtlm* ntlm = rpc->NtlmHttpOut->ntlm;
http_response = http_response_recv(rpc->TlsOut);
ntlm_token_data = NULL;
+
if (http_response && ListDictionary_Contains(http_response->Authenticates, "NTLM"))
{
- char *token64 = ListDictionary_GetItemValue(http_response->Authenticates, "NTLM");
+ char* token64 = ListDictionary_GetItemValue(http_response->Authenticates, "NTLM");
crypto_base64_decode(token64, strlen(token64), &ntlm_token_data, &ntlm_token_length);
}
+
ntlm->inputBuffer[0].pvBuffer = ntlm_token_data;
ntlm->inputBuffer[0].cbBuffer = ntlm_token_length;
{
rdpNtlmHttp* ntlm_http;
- ntlm_http = (rdpNtlmHttp *)calloc(1, sizeof(rdpNtlmHttp));
+ ntlm_http = (rdpNtlmHttp*) calloc(1, sizeof(rdpNtlmHttp));
if (!ntlm_http)
return NULL;
ntlm_http->ntlm = ntlm_new();
+
if (!ntlm_http->ntlm)
goto out_free;
ntlm_http->context = http_context_new();
+
if (!ntlm_http->context)
goto out_free_ntlm;
ntlm->outputBuffer[0].BufferType = SECBUFFER_TOKEN;
ntlm->outputBuffer[0].cbBuffer = ntlm->cbMaxToken;
ntlm->outputBuffer[0].pvBuffer = malloc(ntlm->outputBuffer[0].cbBuffer);
+
if (!ntlm->outputBuffer[0].pvBuffer)
return FALSE;
rdpNtlm* ntlm_new()
{
- return (rdpNtlm *)calloc(1, sizeof(rdpNtlm));
+ return (rdpNtlm*) calloc(1, sizeof(rdpNtlm));
}
void ntlm_free(rdpNtlm* ntlm)
{
- if (ntlm != NULL)
+ if (ntlm)
{
+ if (ntlm->outputBuffer[0].pvBuffer)
+ {
+ free(ntlm->outputBuffer[0].pvBuffer);
+ ntlm->outputBuffer[0].pvBuffer = NULL;
+ }
+
free(ntlm);
}
}
return NULL;
connection->State = VIRTUAL_CONNECTION_STATE_INITIAL;
- connection->DefaultInChannel = (RpcInChannel*)calloc(1, sizeof(RpcInChannel));
+ connection->DefaultInChannel = (RpcInChannel*) calloc(1, sizeof(RpcInChannel));
if (!connection->DefaultInChannel)
goto out_free;
- connection->DefaultOutChannel = (RpcOutChannel*)calloc(1, sizeof(RpcOutChannel));
+ connection->DefaultOutChannel = (RpcOutChannel*) calloc(1, sizeof(RpcOutChannel));
if (!connection->DefaultOutChannel)
goto out_default_in;
return NULL;
}
-void rpc_client_virtual_connection_free(RpcVirtualConnection* virtual_connection)
+void rpc_client_virtual_connection_free(RpcVirtualConnection* virtualConnection)
{
- if (virtual_connection != NULL)
+ if (virtualConnection)
{
- free(virtual_connection->DefaultInChannel);
- free(virtual_connection->DefaultOutChannel);
- free(virtual_connection);
+ CloseHandle(virtualConnection->DefaultInChannel->Mutex);
+ CloseHandle(virtualConnection->DefaultOutChannel->Mutex);
+ free(virtualConnection->DefaultInChannel);
+ free(virtualConnection->DefaultOutChannel);
+ free(virtualConnection);
}
}
rpc->transport = transport;
rpc->settings = transport->settings;
rpc->SendSeqNum = 0;
+
rpc->ntlm = ntlm_new();
if (!rpc->ntlm)
rpc_ntlm_http_init_channel(rpc, rpc->NtlmHttpIn, TSG_CHANNEL_IN);
rpc_ntlm_http_init_channel(rpc, rpc->NtlmHttpOut, TSG_CHANNEL_OUT);
+
rpc->PipeCallId = 0;
rpc->StubCallId = 0;
rpc->StubFragCount = 0;
rpc->KeepAliveInterval = 300000;
rpc->CurrentKeepAliveInterval = rpc->KeepAliveInterval;
rpc->CurrentKeepAliveTime = 0;
+
rpc->VirtualConnection = rpc_client_virtual_connection_new(rpc);
if (!rpc->VirtualConnection)
void rpc_free(rdpRpc* rpc)
{
- if (rpc != NULL)
+ if (rpc)
{
rpc_client_stop(rpc);
- if (rpc->State >= RPC_CLIENT_STATE_CONTEXT_NEGOTIATED)
+ if (rpc->ntlm)
{
ntlm_client_uninit(rpc->ntlm);
ntlm_free(rpc->ntlm);
+ rpc->ntlm = NULL;
+ }
+
+ if (rpc->NtlmHttpIn)
+ {
+ ntlm_http_free(rpc->NtlmHttpIn);
+ rpc->NtlmHttpIn = NULL;
+ }
+
+ if (rpc->NtlmHttpOut)
+ {
+ ntlm_http_free(rpc->NtlmHttpOut);
+ rpc->NtlmHttpOut = NULL;
}
rpc_client_virtual_connection_free(rpc->VirtualConnection);
ArrayList_Clear(rpc->VirtualConnectionCookieTable);
ArrayList_Free(rpc->VirtualConnectionCookieTable);
+
free(rpc);
}
}
DEBUG_RPC("Sending bind PDU");
+ if (rpc->ntlm)
+ {
+ ntlm_free(rpc->ntlm);
+ rpc->ntlm = NULL;
+ }
+
rpc->ntlm = ntlm_new();
+
if (!rpc->ntlm)
return -1;
int rpc_client_new(rdpRpc* rpc)
{
- RpcClient* client = NULL;
- client = (RpcClient*)calloc(1, sizeof(RpcClient));
- rpc->client = client;
+ RpcClient* client;
- if (!client)
- return -1;
+ client = (RpcClient*) calloc(1, sizeof(RpcClient));
- client->Thread = CreateThread(NULL, 0,
- (LPTHREAD_START_ROUTINE) rpc_client_thread,
- rpc, CREATE_SUSPENDED, NULL);
+ rpc->client = client;
- if (!client->Thread)
+ if (!client)
return -1;
client->StopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
int rpc_client_start(rdpRpc* rpc)
{
rpc->client->Thread = CreateThread(NULL, 0,
- (LPTHREAD_START_ROUTINE) rpc_client_thread,
- rpc, 0, NULL);
+ (LPTHREAD_START_ROUTINE) rpc_client_thread, rpc, 0, NULL);
+
return 0;
}
rpc_client_start(rpc);
pdu = rpc_recv_dequeue_pdu(rpc);
+
if (!pdu)
return FALSE;
RpcClientCall* call;
rdpRpc* rpc = tsg->rpc;
rdpSettings* settings = rpc->settings;
+
tsg->Port = port;
+
+ free(tsg->Hostname);
+ tsg->Hostname = NULL;
ConvertToUnicode(CP_UTF8, 0, hostname, -1, &tsg->Hostname, 0);
+
+ free(tsg->MachineName);
+ tsg->MachineName = NULL;
ConvertToUnicode(CP_UTF8, 0, settings->ComputerName, -1, &tsg->MachineName, 0);
if (!rpc_connect(rpc))
{
- WLog_ERR(TAG, "rpc_connect failed!");
+ WLog_ERR(TAG, "rpc_connect failed!");
return FALSE;
}
rdpTsg* tsg_new(rdpTransport* transport)
{
rdpTsg* tsg;
+
tsg = (rdpTsg*) calloc(1, sizeof(rdpTsg));
if (!tsg)
{
if (tsg)
{
+ free(tsg->Hostname);
free(tsg->MachineName);
rpc_free(tsg->rpc);
free(tsg);
free(settings->RedirectionTsvUrl);
free(settings->RemoteAssistanceSessionId);
free(settings->AuthenticationServiceClass);
+ free(settings->GatewayHostname);
+ free(settings->GatewayUsername);
+ free(settings->GatewayPassword);
+ free(settings->GatewayDomain);
freerdp_target_net_addresses_free(settings);
freerdp_device_collection_free(settings);
freerdp_static_channel_collection_free(settings);
rdpSettings* settings = transport->settings;
instance = (freerdp*) transport->settings->instance;
context = instance->context;
+
tsg = tsg_new(transport);
if (!tsg)
transport->TcpIn = NULL;
transport->TcpOut = NULL;
- tsg_free(transport->tsg);
- transport->tsg = NULL;
+
+ if (transport->tsg)
+ {
+ tsg_free(transport->tsg);
+ transport->tsg = NULL;
+ }
+
+ if (transport->TsgTls)
+ {
+ tls_free(transport->TsgTls);
+ transport->TsgTls = NULL;
+ }
+
DeleteCriticalSection(&(transport->ReadLock));
DeleteCriticalSection(&(transport->WriteLock));
+
free(transport);
}
EnterCriticalSection(&listDictionary->lock);
item = (wListDictionaryItem*) malloc(sizeof(wListDictionaryItem));
+
if (!item)
return FALSE;
if (listDictionary->synchronized)
LeaveCriticalSection(&listDictionary->lock);
+
return TRUE;
}