diff --git a/channels/cliprdr/client/cliprdr_main.c b/channels/cliprdr/client/cliprdr_main.c index c604840a8..0045e2d0a 100644 --- a/channels/cliprdr/client/cliprdr_main.c +++ b/channels/cliprdr/client/cliprdr_main.c @@ -409,6 +409,8 @@ static void cliprdr_order_recv(cliprdrPlugin* cliprdr, wStream* s) WLog_ERR(TAG, "unknown msgType %d", msgType); break; } + + Stream_Free(s, TRUE); } /** @@ -890,6 +892,8 @@ static void cliprdr_virtual_channel_event_terminated(cliprdrPlugin* cliprdr) cliprdr_remove_open_handle_data(cliprdr->OpenHandle); cliprdr_remove_init_handle_data(cliprdr->InitHandle); + + free(cliprdr); } static VOID VCAPITYPE cliprdr_virtual_channel_init_event(LPVOID pInitHandle, UINT event, LPVOID pData, UINT dataLength) diff --git a/channels/drive/client/drive_main.c b/channels/drive/client/drive_main.c index 48a15d589..fb3c978e8 100644 --- a/channels/drive/client/drive_main.c +++ b/channels/drive/client/drive_main.c @@ -620,6 +620,9 @@ static void drive_free(DEVICE* device) CloseHandle(drive->thread); ListDictionary_Free(drive->files); + MessageQueue_Free(drive->IrpQueue); + + Stream_Free(drive->device.data, TRUE); free(drive); } diff --git a/channels/rdpdr/client/rdpdr_main.c b/channels/rdpdr/client/rdpdr_main.c index 14ee6d78f..17a63f383 100644 --- a/channels/rdpdr/client/rdpdr_main.c +++ b/channels/rdpdr/client/rdpdr_main.c @@ -999,6 +999,8 @@ static void rdpdr_virtual_channel_event_terminated(rdpdrPlugin* rdpdr) rdpdr_remove_open_handle_data(rdpdr->OpenHandle); rdpdr_remove_init_handle_data(rdpdr->InitHandle); + + free(rdpdr); } static VOID VCAPITYPE rdpdr_virtual_channel_init_event(LPVOID pInitHandle, UINT event, LPVOID pData, UINT dataLength) diff --git a/channels/rdpsnd/client/rdpsnd_main.c b/channels/rdpsnd/client/rdpsnd_main.c index 06c7bde74..ac3872eae 100644 --- a/channels/rdpsnd/client/rdpsnd_main.c +++ b/channels/rdpsnd/client/rdpsnd_main.c @@ -1010,6 +1010,8 @@ static void rdpsnd_virtual_channel_event_terminated(rdpsndPlugin* rdpsnd) rdpsnd->data_in = NULL; } + MessagePipe_Free(rdpsnd->MsgPipe); + if (rdpsnd->device) IFCALL(rdpsnd->device->Free, rdpsnd->device); @@ -1029,6 +1031,8 @@ static void rdpsnd_virtual_channel_event_terminated(rdpsndPlugin* rdpsnd) rdpsnd_remove_open_handle_data(rdpsnd->OpenHandle); rdpsnd_remove_init_handle_data(rdpsnd->InitHandle); + + free(rdpsnd); } static VOID VCAPITYPE rdpsnd_virtual_channel_init_event(LPVOID pInitHandle, UINT event, LPVOID pData, UINT dataLength) @@ -1065,12 +1069,10 @@ BOOL VCAPITYPE VirtualChannelEntry(PCHANNEL_ENTRY_POINTS pEntryPoints) { rdpsndPlugin* rdpsnd; - rdpsnd = (rdpsndPlugin*) malloc(sizeof(rdpsndPlugin)); + rdpsnd = (rdpsndPlugin*) calloc(1, sizeof(rdpsndPlugin)); if (rdpsnd) { - ZeroMemory(rdpsnd, sizeof(rdpsndPlugin)); - #if !defined(_WIN32) && !defined(ANDROID) { sigset_t mask; diff --git a/channels/remdesk/server/remdesk_main.c b/channels/remdesk/server/remdesk_main.c index 8cdc4aba7..8e37e22be 100644 --- a/channels/remdesk/server/remdesk_main.c +++ b/channels/remdesk/server/remdesk_main.c @@ -156,6 +156,8 @@ static int remdesk_send_ctl_version_info_pdu(RemdeskServerContext* context) remdesk_virtual_channel_write(context, s); + Stream_Free(s, TRUE); + return 1; } diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index 1c88da092..63e02eed8 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -1618,7 +1618,6 @@ void* xf_thread(void *param) if (!exit_code) exit_code = freerdp_error_info(instance); - freerdp_channels_free(channels); freerdp_disconnect(instance); gdi_free(instance); @@ -1797,6 +1796,12 @@ static void xfreerdp_client_free(freerdp* instance, rdpContext* context) if (xfc->display) XCloseDisplay(xfc->display); + + if (context->channels) + { + freerdp_channels_free(context->channels); + context->channels = NULL; + } } } diff --git a/client/X11/xf_cliprdr.c b/client/X11/xf_cliprdr.c index 7ba1e4a9f..6956d342a 100644 --- a/client/X11/xf_cliprdr.c +++ b/client/X11/xf_cliprdr.c @@ -296,6 +296,7 @@ static void xf_cliprdr_process_requested_data(xfClipboard* clipboard, BOOL hasDa { case CF_TEXT: case CF_UNICODETEXT: + size = strlen((char*) data) + 1; formatId = ClipboardGetFormatId(clipboard->system, "UTF8_STRING"); break; @@ -304,6 +305,7 @@ static void xf_cliprdr_process_requested_data(xfClipboard* clipboard, BOOL hasDa break; case CB_FORMAT_HTML: + size = strlen((char*) data) + 1; formatId = ClipboardGetFormatId(clipboard->system, "text/html"); break; } @@ -317,8 +319,9 @@ static void xf_cliprdr_process_requested_data(xfClipboard* clipboard, BOOL hasDa CopyMemory(pSrcData, data, SrcSize); bSuccess = ClipboardSetData(clipboard->system, formatId, (void*) pSrcData, SrcSize); + if (!bSuccess) - free (pSrcData); + free(pSrcData); pFormatIds = NULL; count = ClipboardGetFormatIds(clipboard->system, &pFormatIds); @@ -367,6 +370,7 @@ static void xf_cliprdr_process_requested_data(xfClipboard* clipboard, BOOL hasDa } xf_cliprdr_send_data_response(clipboard, pDstData, (int) DstSize); + free(pDstData); } static BOOL xf_cliprdr_get_requested_data(xfClipboard* clipboard, Atom target) @@ -398,6 +402,7 @@ static BOOL xf_cliprdr_get_requested_data(xfClipboard* clipboard, Atom target) XFree(data); data = NULL; } + if (bytes_left <= 0 && !clipboard->incr_starts) { @@ -994,6 +999,7 @@ static int xf_cliprdr_server_format_data_response(CliprdrClientContext* context, CopyMemory(pSrcData, data, SrcSize); bSuccess = ClipboardSetData(clipboard->system, formatId, (void*) pSrcData, SrcSize); + if (!bSuccess) free (pSrcData); @@ -1142,6 +1148,12 @@ void xf_clipboard_free(xfClipboard* clipboard) clipboard->serverFormats = NULL; } + if (clipboard->numClientFormats) + { + for (i = 0; i < clipboard->numClientFormats; i++) + free(clipboard->clientFormats[i].formatName); + } + ClipboardDestroy(clipboard->system); free(clipboard->data); diff --git a/client/common/cmdline.c b/client/common/cmdline.c index 69079cb2e..a34531763 100644 --- a/client/common/cmdline.c +++ b/client/common/cmdline.c @@ -2089,12 +2089,25 @@ int freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings) } } + if (settings->LyncRdpMode) + { + settings->EncomspVirtualChannel = TRUE; + settings->RemdeskVirtualChannel = TRUE; + settings->CompressionEnabled = FALSE; + } + if (settings->RemoteAssistanceMode) { - freerdp_client_load_static_channel_addin(channels, settings, "encomsp", settings); - freerdp_client_load_static_channel_addin(channels, settings, "remdesk", settings); + settings->EncomspVirtualChannel = TRUE; + settings->RemdeskVirtualChannel = TRUE; } + if (settings->EncomspVirtualChannel) + freerdp_client_load_static_channel_addin(channels, settings, "encomsp", settings); + + if (settings->RemdeskVirtualChannel) + freerdp_client_load_static_channel_addin(channels, settings, "remdesk", settings); + for (index = 0; index < settings->StaticChannelCount; index++) { args = settings->StaticChannelArray[index]; diff --git a/cmake/FindPulse.cmake b/cmake/FindPulse.cmake index 7c5ae83ed..acfc2c161 100644 --- a/cmake/FindPulse.cmake +++ b/cmake/FindPulse.cmake @@ -10,5 +10,21 @@ find_library(PULSE_LIBRARY pulse PATHS ${PULSE_LIBRARY_DIRS}) FIND_PACKAGE_HANDLE_STANDARD_ARGS(Pulse DEFAULT_MSG PULSE_INCLUDE_DIR PULSE_LIBRARY) -mark_as_advanced(PULSE_INCLUDE_DIR PULSE_LIBRARY) +if(PULSE_LIBRARY) + file(STRINGS "${PULSE_INCLUDE_DIR}/pulse/version.h" STR1 REGEX "PA_MAJOR") + file(STRINGS "${PULSE_INCLUDE_DIR}/pulse/version.h" STR2 REGEX "PA_MINOR") + file(STRINGS "${PULSE_INCLUDE_DIR}/pulse/version.h" STR3 REGEX "PA_MICRO") + + string(REGEX MATCHALL "[0-9]+" PULSE_VERSION_MAJOR ${STR1}) + string(REGEX MATCHALL "[0-9]+" PULSE_VERSION_MINOR ${STR2}) + string(REGEX MATCHALL "[0-9]+" PULSE_VERSION_PATCH ${STR3}) + + if(PULSE_VERSION_PATCH EQUAL 0) + set(PULSE_VERSION "${PULSE_VERSION_MAJOR}.${PULSE_VERSION_MINOR}") + else() + set(PULSE_VERSION "${PULSE_VERSION_MAJOR}.${PULSE_VERSION_MINOR}.${PULSE_VERSION_PATCH}") + endif() +endif() + +mark_as_advanced(PULSE_INCLUDE_DIR PULSE_LIBRARY PULSE_VERSION PULSE_VERSION_MAJOR PULSE_VERSION_MINOR PULSE_VERSION_PATCH) diff --git a/include/freerdp/channels/channels.h b/include/freerdp/channels/channels.h index ce512de64..9cf3e64bb 100644 --- a/include/freerdp/channels/channels.h +++ b/include/freerdp/channels/channels.h @@ -43,7 +43,6 @@ FREERDP_API int freerdp_channels_post_connect(rdpChannels* channels, freerdp* in FREERDP_API BOOL freerdp_channels_get_fds(rdpChannels* channels, freerdp* instance, void** read_fds, int* read_count, void** write_fds, int* write_count); FREERDP_API BOOL freerdp_channels_check_fds(rdpChannels* channels, freerdp* instance); -FREERDP_API wMessage* freerdp_channels_pop_event(rdpChannels* channels); FREERDP_API void freerdp_channels_close(rdpChannels* channels, freerdp* instance); FREERDP_API void* freerdp_channels_get_static_channel_interface(rdpChannels* channels, const char* name); diff --git a/include/freerdp/settings.h b/include/freerdp/settings.h index 1adcf36dd..ce914b119 100644 --- a/include/freerdp/settings.h +++ b/include/freerdp/settings.h @@ -599,6 +599,9 @@ typedef struct _RDPDR_PARALLEL RDPDR_PARALLEL; #define FreeRDP_RemoteAssistancePassStub 1026 #define FreeRDP_RemoteAssistancePassword 1027 #define FreeRDP_RemoteAssistanceRCTicket 1028 +#define FreeRDP_EncomspVirtualChannel 1029 +#define FreeRDP_RemdeskVirtualChannel 1030 +#define FreeRDP_LyncRdpMode 1031 #define FreeRDP_TlsSecurity 1088 #define FreeRDP_NlaSecurity 1089 #define FreeRDP_RdpSecurity 1090 @@ -972,7 +975,10 @@ struct rdp_settings ALIGN64 char* RemoteAssistancePassStub; /* 1026 */ ALIGN64 char* RemoteAssistancePassword; /* 1027 */ ALIGN64 char* RemoteAssistanceRCTicket; /* 1028 */ - UINT64 padding1088[1088 - 1029]; /* 1029 */ + ALIGN64 BOOL EncomspVirtualChannel; /* 1029 */ + ALIGN64 BOOL RemdeskVirtualChannel; /* 1030 */ + ALIGN64 BOOL LyncRdpMode; /* 1031 */ + UINT64 padding1088[1088 - 1032]; /* 1032 */ /** * X.224 Connection Request/Confirm diff --git a/libfreerdp/cache/glyph.c b/libfreerdp/cache/glyph.c index 30405519b..f6bd2a592 100644 --- a/libfreerdp/cache/glyph.c +++ b/libfreerdp/cache/glyph.c @@ -150,7 +150,7 @@ void update_process_glyph_fragments(rdpContext* context, BYTE* data, UINT32 leng size = data[index + 2]; fragments = (BYTE*) malloc(size); - memcpy(fragments, data, size); + CopyMemory(fragments, data, size); glyph_cache_fragment_put(glyph_cache, id, size, fragments); index += 3; @@ -494,14 +494,12 @@ rdpGlyphCache* glyph_cache_new(rdpSettings* settings) { rdpGlyphCache* glyphCache; - glyphCache = (rdpGlyphCache*) malloc(sizeof(rdpGlyphCache)); + glyphCache = (rdpGlyphCache*) calloc(1, sizeof(rdpGlyphCache)); if (glyphCache) { int i; - ZeroMemory(glyphCache, sizeof(rdpGlyphCache)); - WLog_Init(); glyphCache->log = WLog_Get("com.freerdp.cache.glyph"); @@ -512,12 +510,10 @@ rdpGlyphCache* glyph_cache_new(rdpSettings* settings) { glyphCache->glyphCache[i].number = settings->GlyphCache[i].cacheEntries; glyphCache->glyphCache[i].maxCellSize = settings->GlyphCache[i].cacheMaximumCellSize; - glyphCache->glyphCache[i].entries = (rdpGlyph**) malloc(sizeof(rdpGlyph*) * glyphCache->glyphCache[i].number); - ZeroMemory(glyphCache->glyphCache[i].entries, sizeof(rdpGlyph*) * glyphCache->glyphCache[i].number); + glyphCache->glyphCache[i].entries = (rdpGlyph**) calloc(glyphCache->glyphCache[i].number, sizeof(rdpGlyph*)); } - glyphCache->fragCache.entries = malloc(sizeof(FRAGMENT_CACHE_ENTRY) * 256); - ZeroMemory(glyphCache->fragCache.entries, sizeof(FRAGMENT_CACHE_ENTRY) * 256); + glyphCache->fragCache.entries = calloc(256, sizeof(FRAGMENT_CACHE_ENTRY)); } return glyphCache; @@ -555,10 +551,9 @@ void glyph_cache_free(rdpGlyphCache* glyphCache) glyphCache->glyphCache[i].entries = NULL; } - for (i = 0; i < 255; i++) + for (i = 0; i < 256; i++) { - fragment = glyphCache->fragCache.entries[i].fragment; - free(fragment); + free(glyphCache->fragCache.entries[i].fragment); glyphCache->fragCache.entries[i].fragment = NULL; } diff --git a/libfreerdp/core/client.c b/libfreerdp/core/client.c index fd9c7c519..daa8dbfcc 100644 --- a/libfreerdp/core/client.c +++ b/libfreerdp/core/client.c @@ -98,8 +98,22 @@ rdpChannels* freerdp_channels_new(void) void freerdp_channels_free(rdpChannels* channels) { + int index; + CHANNEL_OPEN_DATA* pChannelOpenData; + MessagePipe_Free(channels->MsgPipe); + for (index = 0; index < channels->clientDataCount; index++) + { + pChannelOpenData = &channels->openDataList[index]; + + if (pChannelOpenData->pInterface) + { + free(pChannelOpenData->pInterface); + pChannelOpenData->pInterface = NULL; + } + } + free(channels); } @@ -265,7 +279,6 @@ static int freerdp_channels_process_sync(rdpChannels* channels, freerdp* instanc { int status = TRUE; wMessage message; - wMessage* event; rdpMcsChannel* channel; CHANNEL_OPEN_EVENT* item; CHANNEL_OPEN_DATA* pChannelOpenData; @@ -302,8 +315,6 @@ static int freerdp_channels_process_sync(rdpChannels* channels, freerdp* instanc } else if (message.id == 1) { - event = (wMessage*) message.wParam; - /** * Ignore for now, the same event is being pushed on the In queue, * and we're pushing it on the Out queue just to wake other threads @@ -384,22 +395,6 @@ BOOL freerdp_channels_check_fds(rdpChannels* channels, freerdp* instance) return TRUE; } -wMessage* freerdp_channels_pop_event(rdpChannels* channels) -{ - wMessage message; - wMessage* event = NULL; - - if (MessageQueue_Peek(channels->MsgPipe->In, &message, TRUE)) - { - if (message.id == 1) - { - event = (wMessage*) message.wParam; - } - } - - return event; -} - void freerdp_channels_close(rdpChannels* channels, freerdp* instance) { int index; diff --git a/libfreerdp/core/orders.c b/libfreerdp/core/orders.c index 7d00b7dfb..50c3b3cd7 100644 --- a/libfreerdp/core/orders.c +++ b/libfreerdp/core/orders.c @@ -1623,47 +1623,46 @@ BOOL update_write_fast_index_order(wStream* s, ORDER_INFO* orderInfo, FAST_INDEX return TRUE; } -BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ORDER* fast_glyph) +BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ORDER* fastGlyph) { BYTE* phold; - GLYPH_DATA_V2* glyph; + GLYPH_DATA_V2* glyph = &fastGlyph->glyphData; - ORDER_FIELD_BYTE(1, fast_glyph->cacheId); - ORDER_FIELD_2BYTE(2, fast_glyph->ulCharInc, fast_glyph->flAccel); - ORDER_FIELD_COLOR(3, fast_glyph->backColor); - ORDER_FIELD_COLOR(4, fast_glyph->foreColor); - ORDER_FIELD_COORD(5, fast_glyph->bkLeft); - ORDER_FIELD_COORD(6, fast_glyph->bkTop); - ORDER_FIELD_COORD(7, fast_glyph->bkRight); - ORDER_FIELD_COORD(8, fast_glyph->bkBottom); - ORDER_FIELD_COORD(9, fast_glyph->opLeft); - ORDER_FIELD_COORD(10, fast_glyph->opTop); - ORDER_FIELD_COORD(11, fast_glyph->opRight); - ORDER_FIELD_COORD(12, fast_glyph->opBottom); - ORDER_FIELD_COORD(13, fast_glyph->x); - ORDER_FIELD_COORD(14, fast_glyph->y); + ORDER_FIELD_BYTE(1, fastGlyph->cacheId); + ORDER_FIELD_2BYTE(2, fastGlyph->ulCharInc, fastGlyph->flAccel); + ORDER_FIELD_COLOR(3, fastGlyph->backColor); + ORDER_FIELD_COLOR(4, fastGlyph->foreColor); + ORDER_FIELD_COORD(5, fastGlyph->bkLeft); + ORDER_FIELD_COORD(6, fastGlyph->bkTop); + ORDER_FIELD_COORD(7, fastGlyph->bkRight); + ORDER_FIELD_COORD(8, fastGlyph->bkBottom); + ORDER_FIELD_COORD(9, fastGlyph->opLeft); + ORDER_FIELD_COORD(10, fastGlyph->opTop); + ORDER_FIELD_COORD(11, fastGlyph->opRight); + ORDER_FIELD_COORD(12, fastGlyph->opBottom); + ORDER_FIELD_COORD(13, fastGlyph->x); + ORDER_FIELD_COORD(14, fastGlyph->y); if (orderInfo->fieldFlags & ORDER_FIELD_15) { if (Stream_GetRemainingLength(s) < 1) return FALSE; - Stream_Read_UINT8(s, fast_glyph->cbData); + Stream_Read_UINT8(s, fastGlyph->cbData); - if (Stream_GetRemainingLength(s) < fast_glyph->cbData) + if (Stream_GetRemainingLength(s) < fastGlyph->cbData) return FALSE; - CopyMemory(fast_glyph->data, Stream_Pointer(s), fast_glyph->cbData); + CopyMemory(fastGlyph->data, Stream_Pointer(s), fastGlyph->cbData); phold = Stream_Pointer(s); if (!Stream_SafeSeek(s, 1)) return FALSE; - if (fast_glyph->cbData > 1) + if (fastGlyph->cbData > 1) { /* parse optional glyph data */ - glyph = &fast_glyph->glyphData; - glyph->cacheIndex = fast_glyph->data[0]; + glyph->cacheIndex = fastGlyph->data[0]; if (!update_read_2byte_signed(s, &glyph->x) || !update_read_2byte_signed(s, &glyph->y) || @@ -1677,17 +1676,14 @@ BOOL update_read_fast_glyph_order(wStream* s, ORDER_INFO* orderInfo, FAST_GLYPH_ if (Stream_GetRemainingLength(s) < glyph->cb) return FALSE; - if (glyph->aj) + if (glyph->cb) { - free(glyph->aj); - glyph->aj = NULL; + glyph->aj = (BYTE*) realloc(glyph->aj, glyph->cb); + Stream_Read(s, glyph->aj, glyph->cb); } - - glyph->aj = (BYTE*) malloc(glyph->cb); - Stream_Read(s, glyph->aj, glyph->cb); } - Stream_Pointer(s) = phold + fast_glyph->cbData; + Stream_Pointer(s) = phold + fastGlyph->cbData; } return TRUE; diff --git a/libfreerdp/core/peer.c b/libfreerdp/core/peer.c index f9602553f..53afc6006 100644 --- a/libfreerdp/core/peer.c +++ b/libfreerdp/core/peer.c @@ -123,13 +123,16 @@ static int freerdp_peer_virtual_channel_write(freerdp_peer* client, HANDLE hChan UINT32 chunkSize; UINT32 maxChunkSize; UINT32 totalLength; + rdpPeerChannel* peerChannel; + rdpMcsChannel* mcsChannel; rdpRdp* rdp = client->context->rdp; - rdpPeerChannel* peerChannel = (rdpPeerChannel*) hChannel; - rdpMcsChannel* mcsChannel = peerChannel->mcsChannel; if (!hChannel) return -1; + peerChannel = (rdpPeerChannel*) hChannel; + mcsChannel = peerChannel->mcsChannel; + if (peerChannel->channelFlags & WTS_CHANNEL_OPTION_DYNAMIC) return -1; /* not yet supported */ diff --git a/libfreerdp/core/settings.c b/libfreerdp/core/settings.c index f4952a71d..eabb8436d 100644 --- a/libfreerdp/core/settings.c +++ b/libfreerdp/core/settings.c @@ -519,6 +519,17 @@ rdpSettings* freerdp_settings_clone(rdpSettings* settings) _settings->LoadBalanceInfo = NULL; _settings->LoadBalanceInfoLength = 0; + _settings->TargetNetAddress = NULL; + _settings->RedirectionTargetFQDN = NULL; + _settings->RedirectionTargetNetBiosName = NULL; + _settings->RedirectionUsername = NULL; + _settings->RedirectionDomain = NULL; + _settings->RedirectionPassword = NULL; + _settings->RedirectionPasswordLength = 0; + _settings->RedirectionTsvUrl = NULL; + _settings->RedirectionTsvUrlLength = 0; + _settings->TargetNetAddressCount = 0; + _settings->TargetNetAddresses = NULL; if (settings->LoadBalanceInfo && settings->LoadBalanceInfoLength) { diff --git a/libfreerdp/core/update.c b/libfreerdp/core/update.c index 2940b73a5..7ed1febc8 100644 --- a/libfreerdp/core/update.c +++ b/libfreerdp/core/update.c @@ -526,6 +526,12 @@ void update_reset_state(rdpUpdate* update) rdpPrimaryUpdate* primary = update->primary; rdpAltSecUpdate* altsec = update->altsec; + if (primary->fast_glyph.glyphData.aj) + { + free(primary->fast_glyph.glyphData.aj); + primary->fast_glyph.glyphData.aj = NULL; + } + ZeroMemory(&primary->order_info, sizeof(ORDER_INFO)); ZeroMemory(&primary->dstblt, sizeof(DSTBLT_ORDER)); ZeroMemory(&primary->patblt, sizeof(PATBLT_ORDER)); @@ -1707,35 +1713,27 @@ rdpUpdate* update_new(rdpRdp* rdp) const wObject cb = { NULL, NULL, NULL, update_free_queued_message, NULL }; rdpUpdate* update; - update = (rdpUpdate*) malloc(sizeof(rdpUpdate)); + update = (rdpUpdate*) calloc(1, sizeof(rdpUpdate)); if (update) { OFFSCREEN_DELETE_LIST* deleteList; - ZeroMemory(update, sizeof(rdpUpdate)); - WLog_Init(); update->log = WLog_Get("com.freerdp.core.update"); update->bitmap_update.count = 64; - update->bitmap_update.rectangles = (BITMAP_DATA*) malloc(sizeof(BITMAP_DATA) * update->bitmap_update.count); - ZeroMemory(update->bitmap_update.rectangles, sizeof(BITMAP_DATA) * update->bitmap_update.count); + update->bitmap_update.rectangles = (BITMAP_DATA*) calloc(update->bitmap_update.count, sizeof(BITMAP_DATA)); - update->pointer = (rdpPointerUpdate*) malloc(sizeof(rdpPointerUpdate)); - ZeroMemory(update->pointer, sizeof(rdpPointerUpdate)); + update->pointer = (rdpPointerUpdate*) calloc(1, sizeof(rdpPointerUpdate)); - update->primary = (rdpPrimaryUpdate*) malloc(sizeof(rdpPrimaryUpdate)); - ZeroMemory(update->primary, sizeof(rdpPrimaryUpdate)); + update->primary = (rdpPrimaryUpdate*) calloc(1, sizeof(rdpPrimaryUpdate)); - update->secondary = (rdpSecondaryUpdate*) malloc(sizeof(rdpSecondaryUpdate)); - ZeroMemory(update->secondary, sizeof(rdpSecondaryUpdate)); + update->secondary = (rdpSecondaryUpdate*) calloc(1, sizeof(rdpSecondaryUpdate)); - update->altsec = (rdpAltSecUpdate*) malloc(sizeof(rdpAltSecUpdate)); - ZeroMemory(update->altsec, sizeof(rdpAltSecUpdate)); + update->altsec = (rdpAltSecUpdate*) calloc(1, sizeof(rdpAltSecUpdate)); - update->window = (rdpWindowUpdate*) malloc(sizeof(rdpWindowUpdate)); - ZeroMemory(update->window, sizeof(rdpWindowUpdate)); + update->window = (rdpWindowUpdate*) calloc(1, sizeof(rdpWindowUpdate)); deleteList = &(update->altsec->create_offscreen_bitmap.deleteList); deleteList->sIndices = 64; diff --git a/server/shadow/shadow_client.c b/server/shadow/shadow_client.c index a230509bb..30ab90e11 100644 --- a/server/shadow/shadow_client.c +++ b/server/shadow/shadow_client.c @@ -67,6 +67,12 @@ void shadow_client_context_new(freerdp_peer* peer, rdpShadowClient* client) settings->RdpKeyFile = _strdup(settings->PrivateKeyFile); + if (server->ipcSocket) + { + settings->LyncRdpMode = TRUE; + settings->CompressionEnabled = FALSE; + } + client->inLobby = TRUE; client->mayView = server->mayView; client->mayInteract = server->mayInteract; @@ -839,12 +845,15 @@ int shadow_client_subsystem_process_message(rdpShadowClient* client, wMessage* m pointerPosition.xPos = msg->xPos; pointerPosition.yPos = msg->yPos; - if ((msg->xPos != client->pointerX) || (msg->yPos != client->pointerY)) + if (client->activated) { - IFCALL(update->pointer->PointerPosition, context, &pointerPosition); + if ((msg->xPos != client->pointerX) || (msg->yPos != client->pointerY)) + { + IFCALL(update->pointer->PointerPosition, context, &pointerPosition); - client->pointerX = msg->xPos; - client->pointerY = msg->yPos; + client->pointerX = msg->xPos; + client->pointerY = msg->yPos; + } } free(msg); @@ -869,14 +878,17 @@ int shadow_client_subsystem_process_message(rdpShadowClient* client, wMessage* m pointerCached.cacheIndex = pointerColor->cacheIndex; - shadow_client_convert_alpha_pointer_data(msg->pixels, msg->premultiplied, - msg->width, msg->height, pointerColor); + if (client->activated) + { + shadow_client_convert_alpha_pointer_data(msg->pixels, msg->premultiplied, + msg->width, msg->height, pointerColor); - IFCALL(update->pointer->PointerNew, context, &pointerNew); - IFCALL(update->pointer->PointerCached, context, &pointerCached); + IFCALL(update->pointer->PointerNew, context, &pointerNew); + IFCALL(update->pointer->PointerCached, context, &pointerCached); - free(pointerColor->xorMaskData); - free(pointerColor->andMaskData); + free(pointerColor->xorMaskData); + free(pointerColor->andMaskData); + } free(msg->pixels); free(msg); diff --git a/winpr/libwinpr/clipboard/clipboard.c b/winpr/libwinpr/clipboard/clipboard.c index 0817b408f..d3de692c9 100644 --- a/winpr/libwinpr/clipboard/clipboard.c +++ b/winpr/libwinpr/clipboard/clipboard.c @@ -148,7 +148,7 @@ void ClipboardUnlock(wClipboard* clipboard) BOOL ClipboardEmpty(wClipboard* clipboard) { if (!clipboard) - return NULL; + return FALSE; if (clipboard->data) { @@ -540,6 +540,10 @@ void ClipboardDestroy(wClipboard* clipboard) } } + free((void*) clipboard->data); + clipboard->data = NULL; + clipboard->size = 0; + clipboard->numFormats = 0; free(clipboard->formats); diff --git a/winpr/libwinpr/clipboard/synthetic.c b/winpr/libwinpr/clipboard/synthetic.c index bffa2315e..36bec7b8a 100644 --- a/winpr/libwinpr/clipboard/synthetic.c +++ b/winpr/libwinpr/clipboard/synthetic.c @@ -137,7 +137,7 @@ static void* clipboard_synthesize_cf_unicodetext(wClipboard* clipboard, UINT32 f if (status <= 0) return NULL; - *pSize = ((status + 1) * 2); + *pSize = status * 2; } return (void*) pDstData; diff --git a/winpr/libwinpr/thread/thread.c b/winpr/libwinpr/thread/thread.c index 30d8580e4..533fbba9b 100644 --- a/winpr/libwinpr/thread/thread.c +++ b/winpr/libwinpr/thread/thread.c @@ -296,11 +296,9 @@ static void winpr_StartThread(WINPR_THREAD *thread) HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId) { - #ifndef HAVE_EVENTFD_H - int flags; - #endif HANDLE handle; WINPR_THREAD* thread; + thread = (WINPR_THREAD*) calloc(1, sizeof(WINPR_THREAD)); if (!thread) @@ -334,8 +332,10 @@ HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize return NULL; } - flags = fcntl(thread->pipe_fd[0], F_GETFL); - fcntl(thread->pipe_fd[0], F_SETFL, flags | O_NONBLOCK); + { + int flags = fcntl(thread->pipe_fd[0], F_GETFL); + fcntl(thread->pipe_fd[0], F_SETFL, flags | O_NONBLOCK); + } #endif pthread_mutex_init(&thread->mutex, 0);