From e47f1c8b80442affdf84b94fcba3ef5273934156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 19 Jan 2015 12:04:23 -0500 Subject: [PATCH 1/4] channels/smartcard: minor robustness fixes --- .../smartcard/client/smartcard_operations.c | 85 ++++++++++++------- channels/smartcard/client/smartcard_pack.c | 2 +- 2 files changed, 54 insertions(+), 33 deletions(-) diff --git a/channels/smartcard/client/smartcard_operations.c b/channels/smartcard/client/smartcard_operations.c index c0e80e5ce..7c981a041 100644 --- a/channels/smartcard/client/smartcard_operations.c +++ b/channels/smartcard/client/smartcard_operations.c @@ -412,16 +412,21 @@ static UINT32 smartcard_GetStatusChangeA_Call(SMARTCARD_DEVICE* smartcard, SMART GetStatusChange_Return ret; LPSCARD_READERSTATEA rgReaderState = NULL; IRP* irp = operation->irp; - status = ret.ReturnCode = SCardGetStatusChangeA(operation->hContext, call->dwTimeOut, call->rgReaderStates, call->cReaders); + + status = ret.ReturnCode = SCardGetStatusChangeA(operation->hContext, + call->dwTimeOut, call->rgReaderStates, call->cReaders); if (status && (status != SCARD_E_TIMEOUT) && (status != SCARD_E_CANCELLED)) { - call->cReaders=0; + call->cReaders = 0; } ret.cReaders = call->cReaders; ret.rgReaderStates = (ReaderState_Return*) calloc(ret.cReaders, sizeof(ReaderState_Return)); + if (!ret.rgReaderStates) + return STATUS_NO_MEMORY; + for (index = 0; index < ret.cReaders; index++) { ret.rgReaderStates[index].dwCurrentState = call->rgReaderStates[index].dwCurrentState; @@ -484,6 +489,9 @@ static UINT32 smartcard_GetStatusChangeW_Call(SMARTCARD_DEVICE* smartcard, SMART ret.cReaders = call->cReaders; ret.rgReaderStates = (ReaderState_Return*) calloc(ret.cReaders, sizeof(ReaderState_Return)); + if (!ret.rgReaderStates) + return STATUS_NO_MEMORY; + for (index = 0; index < ret.cReaders; index++) { ret.rgReaderStates[index].dwCurrentState = call->rgReaderStates[index].dwCurrentState; @@ -878,9 +886,12 @@ static UINT32 smartcard_Transmit_Decode(SMARTCARD_DEVICE* smartcard, SMARTCARD_O return STATUS_NO_MEMORY; status = smartcard_unpack_transmit_call(smartcard, irp->input, call); + smartcard_trace_transmit_call(smartcard, call); + operation->hContext = smartcard_scard_context_native_from_redir(smartcard, &(call->hContext)); operation->hCard = smartcard_scard_handle_native_from_redir(smartcard, &(call->hCard)); + return status; } @@ -899,11 +910,14 @@ static UINT32 smartcard_Transmit_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPE ret.cbRecvLength = call->cbRecvLength; ret.pbRecvBuffer = (BYTE*) malloc(ret.cbRecvLength); + + if (!ret.pbRecvBuffer) + return STATUS_NO_MEMORY; } ret.pioRecvPci = call->pioRecvPci; status = ret.ReturnCode = SCardTransmit(operation->hCard, call->pioSendPci, call->pbSendBuffer, - call->cbSendLength, ret.pioRecvPci, ret.pbRecvBuffer, &(ret.cbRecvLength)); + call->cbSendLength, ret.pioRecvPci, ret.pbRecvBuffer, &(ret.cbRecvLength)); smartcard_trace_transmit_return(smartcard, &ret); status = smartcard_pack_transmit_return(smartcard, irp->output, &ret); @@ -1087,47 +1101,51 @@ static UINT32 smartcard_LocateCardsByATRA_Decode(SMARTCARD_DEVICE* smartcard, SM static UINT32 smartcard_LocateCardsByATRA_Call(SMARTCARD_DEVICE* smartcard, SMARTCARD_OPERATION* operation, LocateCardsByATRA_Call* call) { LONG status; - DWORD index, index2, index3; BOOL equal; + DWORD i, j, k; GetStatusChange_Return ret; - LPSCARD_READERSTATEA rgReaderState2 = NULL; + LPSCARD_READERSTATEA state = NULL; LPSCARD_READERSTATEA states = NULL; IRP* irp = operation->irp; - states = calloc(call->cReaders, sizeof(SCARD_READERSTATEA)); - for (index = 0; index < call->cReaders; index++) - { - states[index].szReader = (LPCSTR) call->rgReaderStates[index].szReader; - states[index].dwCurrentState = call->rgReaderStates[index].Common.dwCurrentState; - states[index].dwEventState = call->rgReaderStates[index].Common.dwEventState; - states[index].cbAtr = call->rgReaderStates[index].Common.cbAtr; - CopyMemory(&(states[index].rgbAtr), &(call->rgReaderStates[index].Common.rgbAtr), 36); - } + states = (LPSCARD_READERSTATEA) calloc(call->cReaders, sizeof(SCARD_READERSTATEA)); + if (!states) + return STATUS_NO_MEMORY; + + for (i = 0; i < call->cReaders; i++) + { + states[i].szReader = (LPCSTR) call->rgReaderStates[i].szReader; + states[i].dwCurrentState = call->rgReaderStates[i].Common.dwCurrentState; + states[i].dwEventState = call->rgReaderStates[i].Common.dwEventState; + states[i].cbAtr = call->rgReaderStates[i].Common.cbAtr; + CopyMemory(&(states[i].rgbAtr), &(call->rgReaderStates[i].Common.rgbAtr), 36); + } status = ret.ReturnCode = SCardGetStatusChangeA(operation->hContext, 0x000001F4, states, call->cReaders); if (status && (status != SCARD_E_TIMEOUT) && (status != SCARD_E_CANCELLED)) { - call->cReaders=0; + call->cReaders = 0; } - for (index = 0; index < call->cAtrs; index++) + for (i = 0; i < call->cAtrs; i++) { - for (index2 = 0; index2 < call->cReaders; index2++) + for (j = 0; j < call->cReaders; j++) { equal = TRUE; - for (index3 = 0; index3 < call->rgAtrMasks[index].cbAtr; index3++) + + for (k = 0; k < call->rgAtrMasks[i].cbAtr; k++) { - if ((call->rgAtrMasks[index].rgbAtr[index3] & call->rgAtrMasks[index].rgbMask[index3]) != - (states[index2].rgbAtr[index3] & call->rgAtrMasks[index].rgbMask[index3])) + if ((call->rgAtrMasks[i].rgbAtr[k] & call->rgAtrMasks[i].rgbMask[k]) != + (states[j].rgbAtr[k] & call->rgAtrMasks[i].rgbMask[k])) { equal = FALSE; break; } if (equal) { - states[index2].dwEventState |= SCARD_STATE_ATRMATCH; + states[j].dwEventState |= SCARD_STATE_ATRMATCH; } } } @@ -1136,13 +1154,16 @@ static UINT32 smartcard_LocateCardsByATRA_Call(SMARTCARD_DEVICE* smartcard, SMAR ret.cReaders = call->cReaders; ret.rgReaderStates = (ReaderState_Return*) calloc(ret.cReaders, sizeof(ReaderState_Return)); - for (index = 0; index < ret.cReaders; index++) + if (!ret.rgReaderStates) + return STATUS_NO_MEMORY; + + for (i = 0; i < ret.cReaders; i++) { - rgReaderState2 = &states[index]; - ret.rgReaderStates[index].dwCurrentState = rgReaderState2->dwCurrentState; - ret.rgReaderStates[index].dwEventState = rgReaderState2->dwEventState; - ret.rgReaderStates[index].cbAtr = rgReaderState2->cbAtr; - CopyMemory(&(ret.rgReaderStates[index].rgbAtr), &(rgReaderState2->rgbAtr), 32); + state = &states[i]; + ret.rgReaderStates[i].dwCurrentState = state->dwCurrentState; + ret.rgReaderStates[i].dwEventState = state->dwEventState; + ret.rgReaderStates[i].cbAtr = state->cbAtr; + CopyMemory(&(ret.rgReaderStates[i].rgbAtr), &(state->rgbAtr), 32); } free(states); @@ -1154,13 +1175,13 @@ static UINT32 smartcard_LocateCardsByATRA_Call(SMARTCARD_DEVICE* smartcard, SMAR if (call->rgReaderStates) { - for (index = 0; index < call->cReaders; index++) + for (i = 0; i < call->cReaders; i++) { - rgReaderState2 = (LPSCARD_READERSTATEA) &call->rgReaderStates[index]; + state = (LPSCARD_READERSTATEA) &call->rgReaderStates[i]; - if (rgReaderState2->szReader) { - free((void*) rgReaderState2->szReader); - rgReaderState2->szReader = NULL; + if (state->szReader) { + free((void*) state->szReader); + state->szReader = NULL; } } diff --git a/channels/smartcard/client/smartcard_pack.c b/channels/smartcard/client/smartcard_pack.c index bb39c7815..edce82411 100644 --- a/channels/smartcard/client/smartcard_pack.c +++ b/channels/smartcard/client/smartcard_pack.c @@ -2246,7 +2246,7 @@ UINT32 smartcard_unpack_transmit_call(SMARTCARD_DEVICE* smartcard, wStream* s, T if (ioRecvPci.cbExtraBytes > 1024) { WLog_Print(smartcard->log, WLOG_WARN, "Transmit_Call ioRecvPci.cbExtraBytes is out of bounds: %d (max: %d)", - (int) ioSendPci.cbExtraBytes, 1024); + (int) ioRecvPci.cbExtraBytes, 1024); return STATUS_INVALID_PARAMETER; } From 73cfa920a99cea6945ea6ac444da6dd9e87986be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 19 Jan 2015 14:56:02 -0500 Subject: [PATCH 2/4] libwinpr-smartcard: add SCARD_ATTR_CHANNEL_ID --- winpr/libwinpr/smartcard/smartcard_pcsc.c | 47 ++++++++++++++++------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/winpr/libwinpr/smartcard/smartcard_pcsc.c b/winpr/libwinpr/smartcard/smartcard_pcsc.c index e6fa0f4e0..5bad1b42d 100644 --- a/winpr/libwinpr/smartcard/smartcard_pcsc.c +++ b/winpr/libwinpr/smartcard/smartcard_pcsc.c @@ -2218,7 +2218,10 @@ WINSCARDAPI LONG WINAPI PCSC_SCardGetAttrib_Internal(SCARDHANDLE hCard, DWORD dw } status = PCSC_MapErrorCodeToWinSCard(status); - *pcbAttrLen = (DWORD) pcsc_cbAttrLen; + + if (status == SCARD_S_SUCCESS) + *pcbAttrLen = (DWORD) pcsc_cbAttrLen; + return status; } @@ -2338,6 +2341,7 @@ WINSCARDAPI LONG WINAPI PCSC_SCardGetAttrib_FriendlyName(SCARDHANDLE hCard, DWOR } free(namePCSC); + free(nameWinSCard); return status; } @@ -2407,29 +2411,46 @@ WINSCARDAPI LONG WINAPI PCSC_SCardGetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, L { if (dwAttrId == SCARD_ATTR_CURRENT_PROTOCOL_TYPE) { - PCSC_DWORD dwState = 0; - PCSC_DWORD cbAtrLen = 0; - PCSC_DWORD dwProtocol = 0; - PCSC_DWORD cchReaderLen = 0; - status = (LONG) g_PCSC.pfnSCardStatus(hCard, NULL, &cchReaderLen, &dwState, &dwProtocol, NULL, &cbAtrLen); - - if (status == SCARD_S_SUCCESS) + if (!pcbAttrLenAlloc) { - LPDWORD pdwProtocol = (LPDWORD) pbAttr; + PCSC_DWORD dwState = 0; + PCSC_DWORD cbAtrLen = 0; + PCSC_DWORD dwProtocol = 0; + PCSC_DWORD cchReaderLen = 0; + + status = (LONG) g_PCSC.pfnSCardStatus(hCard, NULL, &cchReaderLen, &dwState, &dwProtocol, NULL, &cbAtrLen); + + if (status == SCARD_S_SUCCESS) + { + LPDWORD pdwProtocol = (LPDWORD) pbAttr; + + if (cbAttrLen < sizeof(DWORD)) + return SCARD_E_INSUFFICIENT_BUFFER; + + *pdwProtocol = PCSC_ConvertProtocolsToWinSCard(dwProtocol); + *pcbAttrLen = sizeof(DWORD); + } + } + } + else if (dwAttrId == SCARD_ATTR_CHANNEL_ID) + { + if (!pcbAttrLenAlloc) + { + UINT16 channelType = 0x20; /* USB */ + UINT16 channelNumber = 0; if (cbAttrLen < sizeof(DWORD)) return SCARD_E_INSUFFICIENT_BUFFER; - *pdwProtocol = PCSC_ConvertProtocolsToWinSCard(dwProtocol); + status = SCARD_S_SUCCESS; + + *((DWORD*) pbAttr) = (channelType << 16) | channelNumber; *pcbAttrLen = sizeof(DWORD); } } else if (dwAttrId == SCARD_ATTR_VENDOR_IFD_TYPE) { } - else if (dwAttrId == SCARD_ATTR_CHANNEL_ID) - { - } else if (dwAttrId == SCARD_ATTR_DEFAULT_CLK) { } From 9bc32c2a85fb83c6cfb042922853c8acf574b5fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Tue, 20 Jan 2015 10:15:37 -0500 Subject: [PATCH 3/4] Revert "Moved channel loading, now only loading before connect." This reverts commit f7756efca6f8b9d885842f4b0954afa04d19271e. --- client/X11/xf_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index 92deaa1f4..c9d561d1b 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -925,6 +925,7 @@ BOOL xf_pre_connect(freerdp* instance) PubSub_SubscribeChannelDisconnected(instance->context->pubSub, (pChannelDisconnectedEventHandler) xf_OnChannelDisconnectedEventHandler); + freerdp_client_load_addins(channels, instance->settings); freerdp_channels_pre_connect(channels, instance); if (!settings->Username) @@ -1812,7 +1813,6 @@ static int xfreerdp_client_new(freerdp* instance, rdpContext* context) settings = instance->settings; xfc->settings = instance->context->settings; - freerdp_client_load_addins(context->channels, instance->settings); PubSub_SubscribeTerminate(context->pubSub, (pTerminateEventHandler) xf_TerminateEventHandler); #ifdef WITH_XRENDER From 4fe932f21fbce7eef814587f8cf3e8e309ed3f9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Tue, 20 Jan 2015 10:46:32 -0500 Subject: [PATCH 4/4] libfreerdp-core: cleanup redirection debug output --- libfreerdp/core/redirection.c | 81 ++++++++++++++++++----------------- libfreerdp/core/redirection.h | 1 - 2 files changed, 41 insertions(+), 41 deletions(-) diff --git a/libfreerdp/core/redirection.c b/libfreerdp/core/redirection.c index 5c2048d66..2bcb1928c 100644 --- a/libfreerdp/core/redirection.c +++ b/libfreerdp/core/redirection.c @@ -32,48 +32,48 @@ void rdp_print_redirection_flags(UINT32 flags) { - WLog_INFO(TAG, "redirectionFlags = {"); + WLog_DBG(TAG, "redirectionFlags = {"); if (flags & LB_TARGET_NET_ADDRESS) - WLog_INFO(TAG, "\tLB_TARGET_NET_ADDRESS"); + WLog_DBG(TAG, "\tLB_TARGET_NET_ADDRESS"); if (flags & LB_LOAD_BALANCE_INFO) - WLog_INFO(TAG, "\tLB_LOAD_BALANCE_INFO"); + WLog_DBG(TAG, "\tLB_LOAD_BALANCE_INFO"); if (flags & LB_USERNAME) - WLog_INFO(TAG, "\tLB_USERNAME"); + WLog_DBG(TAG, "\tLB_USERNAME"); if (flags & LB_DOMAIN) - WLog_INFO(TAG, "\tLB_DOMAIN"); + WLog_DBG(TAG, "\tLB_DOMAIN"); if (flags & LB_PASSWORD) - WLog_INFO(TAG, "\tLB_PASSWORD"); + WLog_DBG(TAG, "\tLB_PASSWORD"); if (flags & LB_DONTSTOREUSERNAME) - WLog_INFO(TAG, "\tLB_DONTSTOREUSERNAME"); + WLog_DBG(TAG, "\tLB_DONTSTOREUSERNAME"); if (flags & LB_SMARTCARD_LOGON) - WLog_INFO(TAG, "\tLB_SMARTCARD_LOGON"); + WLog_DBG(TAG, "\tLB_SMARTCARD_LOGON"); if (flags & LB_NOREDIRECT) - WLog_INFO(TAG, "\tLB_NOREDIRECT"); + WLog_DBG(TAG, "\tLB_NOREDIRECT"); if (flags & LB_TARGET_FQDN) - WLog_INFO(TAG, "\tLB_TARGET_FQDN"); + WLog_DBG(TAG, "\tLB_TARGET_FQDN"); if (flags & LB_TARGET_NETBIOS_NAME) - WLog_INFO(TAG, "\tLB_TARGET_NETBIOS_NAME"); + WLog_DBG(TAG, "\tLB_TARGET_NETBIOS_NAME"); if (flags & LB_TARGET_NET_ADDRESSES) - WLog_INFO(TAG, "\tLB_TARGET_NET_ADDRESSES"); + WLog_DBG(TAG, "\tLB_TARGET_NET_ADDRESSES"); if (flags & LB_CLIENT_TSV_URL) - WLog_INFO(TAG, "\tLB_CLIENT_TSV_URL"); + WLog_DBG(TAG, "\tLB_CLIENT_TSV_URL"); if (flags & LB_SERVER_TSV_CAPABLE) - WLog_INFO(TAG, "\tLB_SERVER_TSV_CAPABLE"); + WLog_DBG(TAG, "\tLB_SERVER_TSV_CAPABLE"); - WLog_INFO(TAG, "}"); + WLog_DBG(TAG, "}"); } BOOL rdp_redirection_read_string(wStream* s, char** str) @@ -103,6 +103,7 @@ int rdp_redirection_apply_settings(rdpRdp* rdp) { rdpSettings* settings = rdp->settings; rdpRedirection* redirection = rdp->redirection; + settings->RedirectionFlags = redirection->flags; settings->RedirectedSessionId = redirection->sessionID; @@ -112,6 +113,10 @@ int rdp_redirection_apply_settings(rdpRdp* rdp) free(settings->LoadBalanceInfo); settings->LoadBalanceInfoLength = redirection->LoadBalanceInfoLength; settings->LoadBalanceInfo = (BYTE*) malloc(settings->LoadBalanceInfoLength); + + if (!settings->LoadBalanceInfo) + return -1; + CopyMemory(settings->LoadBalanceInfo, redirection->LoadBalanceInfo, settings->LoadBalanceInfoLength); } else @@ -201,11 +206,10 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s) Stream_Read_UINT32(s, redirection->sessionID); /* sessionID (4 bytes) */ Stream_Read_UINT32(s, redirection->flags); /* redirFlags (4 bytes) */ - WLog_Print(redirection->log, WLOG_DEBUG, "flags: 0x%04X, redirFlags: 0x%04X length: %d, sessionID: 0x%08X", + WLog_DBG(TAG, "flags: 0x%04X, redirFlags: 0x%04X length: %d, sessionID: 0x%08X", flags, redirection->flags, length, redirection->sessionID); -#ifdef WITH_DEBUG_REDIR + rdp_print_redirection_flags(redirection->flags); -#endif if (redirection->flags & LB_TARGET_NET_ADDRESS) { @@ -225,10 +229,9 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s) redirection->LoadBalanceInfo = (BYTE*) malloc(redirection->LoadBalanceInfoLength); Stream_Read(s, redirection->LoadBalanceInfo, redirection->LoadBalanceInfoLength); -#ifdef WITH_DEBUG_REDIR - DEBUG_REDIR("loadBalanceInfo:"); + + WLog_DBG(TAG, "loadBalanceInfo:"); winpr_HexDump(TAG, WLOG_DEBUG, redirection->LoadBalanceInfo, redirection->LoadBalanceInfoLength); -#endif } if (redirection->flags & LB_USERNAME) @@ -236,7 +239,7 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s) if (!rdp_redirection_read_string(s, &(redirection->Username))) return -1; - WLog_Print(redirection->log, WLOG_DEBUG, "Username: %s", redirection->Username); + WLog_DBG(TAG, "Username: %s", redirection->Username); } if (redirection->flags & LB_DOMAIN) @@ -244,7 +247,7 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s) if (!rdp_redirection_read_string(s, &(redirection->Domain))) return FALSE; - WLog_Print(redirection->log, WLOG_DEBUG, "Domain: %s", redirection->Domain); + WLog_DBG(TAG, "Domain: %s", redirection->Domain); } if (redirection->flags & LB_PASSWORD) @@ -256,10 +259,9 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s) Stream_Read_UINT32(s, redirection->PasswordLength); redirection->Password = (BYTE*) malloc(redirection->PasswordLength); Stream_Read(s, redirection->Password, redirection->PasswordLength); -#ifdef WITH_DEBUG_REDIR - DEBUG_REDIR("PasswordCookie:"); + + WLog_DBG(TAG, "PasswordCookie:"); winpr_HexDump(TAG, WLOG_DEBUG, redirection->Password, redirection->PasswordLength); -#endif } if (redirection->flags & LB_TARGET_FQDN) @@ -267,7 +269,7 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s) if (!rdp_redirection_read_string(s, &(redirection->TargetFQDN))) return -1; - WLog_Print(redirection->log, WLOG_DEBUG, "TargetFQDN: %s", redirection->TargetFQDN); + WLog_DBG(TAG, "TargetFQDN: %s", redirection->TargetFQDN); } if (redirection->flags & LB_TARGET_NETBIOS_NAME) @@ -275,7 +277,7 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s) if (!rdp_redirection_read_string(s, &(redirection->TargetNetBiosName))) return -1; - WLog_Print(redirection->log, WLOG_DEBUG, "TargetNetBiosName: %s", redirection->TargetNetBiosName); + WLog_DBG(TAG, "TargetNetBiosName: %s", redirection->TargetNetBiosName); } if (redirection->flags & LB_CLIENT_TSV_URL) @@ -290,10 +292,9 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s) redirection->TsvUrl = (BYTE*) malloc(redirection->TsvUrlLength); Stream_Read(s, redirection->TsvUrl, redirection->TsvUrlLength); -#ifdef WITH_DEBUG_REDIR - DEBUG_REDIR("TsvUrl:"); + + WLog_DBG(TAG, "TsvUrl:"); winpr_HexDump(TAG, WLOG_DEBUG, redirection->TsvUrl, redirection->TsvUrlLength); -#endif } if (redirection->flags & LB_TARGET_NET_ADDRESSES) @@ -308,16 +309,20 @@ BOOL rdp_recv_server_redirection_pdu(rdpRdp* rdp, wStream* s) Stream_Read_UINT32(s, targetNetAddressesLength); Stream_Read_UINT32(s, redirection->TargetNetAddressesCount); count = redirection->TargetNetAddressesCount; - redirection->TargetNetAddresses = (char**) malloc(count * sizeof(char*)); - ZeroMemory(redirection->TargetNetAddresses, count * sizeof(char*)); - WLog_Print(redirection->log, WLOG_DEBUG, "TargetNetAddressesCount: %d", redirection->TargetNetAddressesCount); + + redirection->TargetNetAddresses = (char**) calloc(count, sizeof(char*)); + + if (!redirection->TargetNetAddresses) + return FALSE; + + WLog_DBG(TAG, "TargetNetAddressesCount: %d", redirection->TargetNetAddressesCount); for (i = 0; i < (int) count; i++) { if (!rdp_redirection_read_string(s, &(redirection->TargetNetAddresses[i]))) return FALSE; - WLog_Print(redirection->log, WLOG_DEBUG, "TargetNetAddresses[%d]: %s", i, redirection->TargetNetAddresses[i]); + WLog_DBG(TAG, "TargetNetAddresses[%d]: %s", i, redirection->TargetNetAddresses[i]); } } @@ -362,11 +367,7 @@ rdpRedirection* redirection_new() if (redirection) { - WLog_Init(); - redirection->log = WLog_Get("com.freerdp.core.redirection"); -#ifdef WITH_DEBUG_REDIR - WLog_SetLogLevel(redirection->log, WLOG_TRACE); -#endif + } return redirection; diff --git a/libfreerdp/core/redirection.h b/libfreerdp/core/redirection.h index 4c239b904..8bf00ce8d 100644 --- a/libfreerdp/core/redirection.h +++ b/libfreerdp/core/redirection.h @@ -32,7 +32,6 @@ typedef struct rdp_redirection rdpRedirection; struct rdp_redirection { - wLog* log; UINT32 flags; UINT32 sessionID; BYTE* TsvUrl;