From 12aae5013a6ceaf476ff3040d3e72910aa586ea7 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 11 Oct 2016 11:13:54 +0200 Subject: [PATCH 1/7] Properly escaping __FILE__ replacement. --- CMakeLists.txt | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b69d61a9..a53898451 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,7 +71,7 @@ include(CMakePackageConfigHelpers) # Soname versioning set(BUILD_NUMBER 0) if ($ENV{BUILD_NUMBER}) - set(BUILD_NUMBER $ENV{BUILD_NUMBER}) + set(BUILD_NUMBER $ENV{BUILD_NUMBER}) endif() set(WITH_LIBRARY_VERSIONING "ON") set(FREERDP_VERSION_MAJOR "2") @@ -135,14 +135,14 @@ if(NOT DEFINED BUILD_SHARED_LIBS) endif() if(BUILD_TESTING) - set(EXPORT_ALL_SYMBOLS TRUE) + set(EXPORT_ALL_SYMBOLS TRUE) elseif(NOT DEFINED EXPORT_ALL_SYMBOLS) - set(EXPORT_ALL_SYMBOLS FALSE) + set(EXPORT_ALL_SYMBOLS FALSE) endif() if (EXPORT_ALL_SYMBOLS) -# set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) - add_definitions(-DFREERDP_TEST_EXPORTS -DBUILD_TESTING) +# set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) + add_definitions(-DFREERDP_TEST_EXPORTS -DBUILD_TESTING) endif(EXPORT_ALL_SYMBOLS) # BSD @@ -235,18 +235,19 @@ if(CMAKE_COMPILER_IS_GNUCC) endif() endif() if(CMAKE_BUILD_TYPE STREQUAL "Release") + set(FILE_SUBST "\"$(subst ${CMAKE_BINARY_DIR}/,,$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<)))\"") add_definitions(-DNDEBUG) CHECK_C_COMPILER_FLAG (-Wno-builtin-macro-redefined Wno-builtin-macro-redefined) if(Wno-builtin-macro-redefined) set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wno-builtin-macro-redefined") - add_definitions("-D__FILE__='\"$(subst ${CMAKE_BINARY_DIR}/,,$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<)))\"'") + add_definitions("-D__FILE__=${FILE_SUBST}") endif() CHECK_CXX_COMPILER_FLAG (-Wno-builtin-macro-redefined Wno-builtin-macro-redefinedCXX) if(Wno-builtin-macro-redefinedCXX) set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-builtin-macro-redefined") - add_definitions("-D__FILE__='\"$(subst ${CMAKE_BINARY_DIR}/,,$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<)))\"'") + add_definitions("-D__FILE__=${FILE_SUBST}") endif() else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") @@ -487,7 +488,7 @@ endif() if(ANDROID) set(WITH_LIBRARY_VERSIONING "OFF") - set_property( GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ${ANDROID_LIBRARY_USE_LIB64_PATHS} ) + set_property( GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ${ANDROID_LIBRARY_USE_LIB64_PATHS} ) if (${ANDROID_ABI} STREQUAL "armeabi") set (WITH_NEON OFF) @@ -808,7 +809,7 @@ endif() include(CTest) if(BUILD_TESTING) - enable_testing() + enable_testing() if(MSVC) set(TESTING_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") @@ -860,7 +861,7 @@ include_directories("${CMAKE_BINARY_DIR}/rdtk/include") add_subdirectory(rdtk) if(WAYLAND_FOUND) - add_subdirectory(uwac) + add_subdirectory(uwac) endif() if(BSD) @@ -906,9 +907,9 @@ include(${CMAKE_CPACK_INCLUDE_FILE}) set(FREERDP_BUILD_CONFIG_LIST "") GET_CMAKE_PROPERTY(res VARIABLES) FOREACH(var ${res}) - IF (var MATCHES "^WITH_*|^BUILD_TESTING|^BUILTIN_CHANNELS|^HAVE_*") - LIST(APPEND FREERDP_BUILD_CONFIG_LIST "${var}=${${var}}") - ENDIF() + IF (var MATCHES "^WITH_*|^BUILD_TESTING|^BUILTIN_CHANNELS|^HAVE_*") + LIST(APPEND FREERDP_BUILD_CONFIG_LIST "${var}=${${var}}") + ENDIF() ENDFOREACH() string(REPLACE ";" " " FREERDP_BUILD_CONFIG "${FREERDP_BUILD_CONFIG_LIST}") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/buildflags.h.in ${CMAKE_CURRENT_BINARY_DIR}/buildflags.h) From 85e17ada02fed2f9cc22711c41a0dd31e7b5ab75 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 11 Oct 2016 11:14:49 +0200 Subject: [PATCH 2/7] Fixed uninitialized arguments, WLog tag. --- include/freerdp/codec/color.h | 36 +++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/include/freerdp/codec/color.h b/include/freerdp/codec/color.h index 0598b7bf8..4d08b7194 100644 --- a/include/freerdp/codec/color.h +++ b/include/freerdp/codec/color.h @@ -24,6 +24,8 @@ #include #include +#include +#define CTAG FREERDP_TAG("codec.color") #define FREERDP_PIXEL_FORMAT_TYPE_A 0 #define FREERDP_PIXEL_FORMAT_TYPE_ARGB 1 @@ -570,6 +572,20 @@ static INLINE void SplitColor(UINT32 color, UINT32 format, BYTE* _r, BYTE* _g, tmp = palette->palette[color]; SplitColor(tmp, palette->format, _r, _g, _b, _a, NULL); } + else + { + if (_r) + *_r = 0x00; + + if (_g) + *_g = 0x00; + + if (_b) + *_b = 0x00; + + if (_a) + *_a = 0x00; + } break; @@ -592,7 +608,19 @@ static INLINE void SplitColor(UINT32 color, UINT32 format, BYTE* _r, BYTE* _g, /* 4 bpp formats */ case PIXEL_FORMAT_A4: default: - WLog_ERR("xxxxx", "Unsupported format %s", GetColorFormatName(format)); + if (_r) + *_r = 0x00; + + if (_g) + *_g = 0x00; + + if (_b) + *_b = 0x00; + + if (_a) + *_a = 0x00; + + WLog_ERR(CTAG, "Unsupported format %s", GetColorFormatName(format)); break; } } @@ -686,7 +714,7 @@ static INLINE UINT32 GetColor(UINT32 format, BYTE r, BYTE g, BYTE b, BYTE a) /* 1bpp formats */ case PIXEL_FORMAT_MONO: default: - WLog_ERR("xxxxx", "Unsupported format %s", GetColorFormatName(format)); + WLog_ERR(CTAG, "Unsupported format %s", GetColorFormatName(format)); return 0; } } @@ -762,7 +790,7 @@ static INLINE UINT32 ReadColor(const BYTE* src, UINT32 format) break; default: - WLog_ERR("xxxxx", "Unsupported format %s", GetColorFormatName(format)); + WLog_ERR(CTAG, "Unsupported format %s", GetColorFormatName(format)); color = 0; break; } @@ -815,7 +843,7 @@ static INLINE BOOL WriteColor(BYTE* dst, UINT32 format, UINT32 color) break; default: - WLog_ERR("xxxxx", "Unsupported format %s", GetColorFormatName(format)); + WLog_ERR(CTAG, "Unsupported format %s", GetColorFormatName(format)); return FALSE; } From ae5689709c55c8a8184465e84a7e949b76195c03 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 11 Oct 2016 11:17:22 +0200 Subject: [PATCH 3/7] Fixed uninitialized variables. --- libfreerdp/gdi/test/TestGdiBitBlt.c | 10 +++++----- libfreerdp/gdi/test/TestGdiLine.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libfreerdp/gdi/test/TestGdiBitBlt.c b/libfreerdp/gdi/test/TestGdiBitBlt.c index e8ed0b1b5..64367e93c 100644 --- a/libfreerdp/gdi/test/TestGdiBitBlt.c +++ b/libfreerdp/gdi/test/TestGdiBitBlt.c @@ -443,8 +443,8 @@ static BOOL test_gdi_BitBlt(UINT32 SrcFormat, UINT32 DstFormat) BOOL rc = FALSE; BOOL failed = FALSE; UINT32 x; - HGDI_DC hdcSrc; - HGDI_DC hdcDst; + HGDI_DC hdcSrc = NULL; + HGDI_DC hdcDst = NULL; const UINT32 RawFormat = PIXEL_FORMAT_RGB8; struct test_bitblt tests[] = { @@ -491,9 +491,9 @@ static BOOL test_gdi_BitBlt(UINT32 SrcFormat, UINT32 DstFormat) {GDI_DPo, bmp_SRC, NULL} }; const UINT32 number_tests = sizeof(tests) / sizeof(tests[0]); - HGDI_BITMAP hBmpSrc; - HGDI_BITMAP hBmpDst; - HGDI_BITMAP hBmpDstOriginal; + HGDI_BITMAP hBmpSrc = NULL; + HGDI_BITMAP hBmpDst = NULL; + HGDI_BITMAP hBmpDstOriginal = NULL; HGDI_BRUSH brush; gdiPalette g; gdiPalette* hPalette = &g; diff --git a/libfreerdp/gdi/test/TestGdiLine.c b/libfreerdp/gdi/test/TestGdiLine.c index b6a815801..f85154ac0 100644 --- a/libfreerdp/gdi/test/TestGdiLine.c +++ b/libfreerdp/gdi/test/TestGdiLine.c @@ -670,8 +670,8 @@ int TestGdiLine(int argc, char* argv[]) for (i = 0; i < number_formats; i++) { - HGDI_DC hdc; - HGDI_PEN pen; + HGDI_DC hdc = NULL; + HGDI_PEN pen = NULL; HGDI_BITMAP hBmp = NULL; struct ropMap rop_map[] = { From 99ade05330b4236ac27accdcd45662341f44195a Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 11 Oct 2016 11:20:26 +0200 Subject: [PATCH 4/7] Fixed uninitialized variable. --- libfreerdp/codec/planar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libfreerdp/codec/planar.c b/libfreerdp/codec/planar.c index cb699044f..ce941b0e5 100644 --- a/libfreerdp/codec/planar.c +++ b/libfreerdp/codec/planar.c @@ -299,7 +299,7 @@ BOOL planar_decompress(BITMAP_PLANAR_CONTEXT* planar, UINT32 subWidth; UINT32 subHeight; UINT32 planeSize; - INT32 rleSizes[4]; + INT32 rleSizes[4] = { 0, 0, 0, 0 }; UINT32 rawSizes[4]; UINT32 rawWidths[4]; UINT32 rawHeights[4]; From d1a28c59f7b99b08fe251b8ec7a7e48e4a5b0107 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 11 Oct 2016 11:20:54 +0200 Subject: [PATCH 5/7] Fixed uninitialized variable. --- libfreerdp/core/freerdp.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/libfreerdp/core/freerdp.c b/libfreerdp/core/freerdp.c index ba9a86e55..35dcae1f9 100644 --- a/libfreerdp/core/freerdp.c +++ b/libfreerdp/core/freerdp.c @@ -94,7 +94,7 @@ rdpChannels* freerdp_channel_get_channels_context(void) */ BOOL freerdp_connect(freerdp* instance) { - UINT status2; + UINT status2 = CHANNEL_RC_OK; rdpRdp* rdp; BOOL status = TRUE; rdpSettings* settings; @@ -116,7 +116,7 @@ BOOL freerdp_connect(freerdp* instance) if (status) status2 = freerdp_channels_pre_connect(instance->context->channels, - instance); + instance); if (settings->KeyboardLayout == KBD_JAPANESE_INPUT_SYSTEM_MS_IME2002) { @@ -153,7 +153,7 @@ BOOL freerdp_connect(freerdp* instance) if (instance->settings->DumpRemoteFx) { instance->update->pcap_rfx = pcap_open(instance->settings->DumpRemoteFxFile, - TRUE); + TRUE); if (instance->update->pcap_rfx) instance->update->dump_rfx = TRUE; @@ -220,7 +220,7 @@ BOOL freerdp_connect(freerdp* instance) if (rdp->errorInfo == ERRINFO_SERVER_INSUFFICIENT_PRIVILEGES) freerdp_set_last_error(instance->context, - FREERDP_ERROR_INSUFFICIENT_PRIVILEGES); + FREERDP_ERROR_INSUFFICIENT_PRIVILEGES); SetEvent(rdp->transport->connectedEvent); freerdp_connect_finally: @@ -239,7 +239,7 @@ BOOL freerdp_abort_connect(freerdp* instance) } BOOL freerdp_get_fds(freerdp* instance, void** rfds, int* rcount, void** wfds, - int* wcount) + int* wcount) { rdpRdp* rdp = instance->context->rdp; transport_get_fds(rdp->transport, rfds, rcount); @@ -278,7 +278,7 @@ BOOL freerdp_check_fds(freerdp* instance) } DWORD freerdp_get_event_handles(rdpContext* context, HANDLE* events, - DWORD count) + DWORD count) { DWORD nCount = 0; nCount += transport_get_event_handles(context->rdp->transport, events, count); @@ -299,8 +299,9 @@ DWORD freerdp_get_event_handles(rdpContext* context, HANDLE* events, { if (nCount >= count) return 0; + events[nCount++] = freerdp_get_message_queue_event_handle( - context->instance, FREERDP_INPUT_MESSAGE_QUEUE); + context->instance, FREERDP_INPUT_MESSAGE_QUEUE); } return nCount; @@ -336,7 +337,7 @@ BOOL freerdp_check_event_handles(rdpContext* context) if (context->settings->AsyncInput) { status = freerdp_message_queue_process_pending_messages( - context->instance, FREERDP_INPUT_MESSAGE_QUEUE); + context->instance, FREERDP_INPUT_MESSAGE_QUEUE); } return status; @@ -373,7 +374,7 @@ HANDLE freerdp_get_message_queue_event_handle(freerdp* instance, DWORD id) } int freerdp_message_queue_process_message(freerdp* instance, DWORD id, - wMessage* message) + wMessage* message) { int status = -1; @@ -410,7 +411,7 @@ int freerdp_message_queue_process_pending_messages(freerdp* instance, DWORD id) } static int freerdp_send_channel_data(freerdp* instance, UINT16 channelId, - BYTE* data, int size) + BYTE* data, int size) { return rdp_send_channel_data(instance->context->rdp, channelId, data, size); } @@ -426,13 +427,12 @@ BOOL freerdp_disconnect(freerdp* instance) if (instance->settings->AsyncInput) { wMessageQueue* inputQueue = freerdp_get_message_queue(instance, - FREERDP_INPUT_MESSAGE_QUEUE); - - MessageQueue_PostQuit(inputQueue, 0); + FREERDP_INPUT_MESSAGE_QUEUE); + MessageQueue_PostQuit(inputQueue, 0); } if (freerdp_channels_disconnect(instance->context->channels, - instance) != CHANNEL_RC_OK) + instance) != CHANNEL_RC_OK) rc = FALSE; IFCALL(instance->PostDisconnect, instance); @@ -574,7 +574,7 @@ BOOL freerdp_context_new(freerdp* instance) goto fail; PubSub_AddEventTypes(context->pubSub, FreeRDP_Events, - sizeof(FreeRDP_Events) / sizeof(wEventType)); + sizeof(FreeRDP_Events) / sizeof(wEventType)); context->metrics = metrics_new(context); if (!context->metrics) @@ -748,7 +748,7 @@ void freerdp_set_last_error(rdpContext* context, UINT32 lastError) { if (lastError) WLog_ERR(TAG, "freerdp_set_last_error %s [0x%04X]", - freerdp_get_last_error_name(lastError), lastError); + freerdp_get_last_error_name(lastError), lastError); context->LastError = lastError; @@ -854,7 +854,7 @@ BOOL checkChannelErrorEvent(rdpContext* context) if (WaitForSingleObject(context->channelErrorEvent, 0) == WAIT_OBJECT_0) { WLog_ERR(TAG, "%s. Error was %lu", context->errorDescription, - context->channelErrorNum); + context->channelErrorNum); return FALSE; } From 8fbc885f198cb0dca58b365db2e67626c77721af Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 11 Oct 2016 11:21:13 +0200 Subject: [PATCH 6/7] Removed unused variable. --- libfreerdp/core/transport.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libfreerdp/core/transport.c b/libfreerdp/core/transport.c index a6ba4b817..8bd610fe8 100644 --- a/libfreerdp/core/transport.c +++ b/libfreerdp/core/transport.c @@ -380,7 +380,6 @@ static void transport_bio_error_log(LPCSTR tag, LPCSTR biofunc, BIO* bio, unsigned long sslerr; char* buf; wLog* log; - wLogMessage log_message; int saveerrno; DWORD level; saveerrno = errno; From d7582b130c7a21dba92994263bfd35bf4eb35154 Mon Sep 17 00:00:00 2001 From: Bernhard Miklautz Date: Wed, 12 Oct 2016 11:24:29 +0200 Subject: [PATCH 7/7] Adapt makefile specific file paths Try to use relative file paths only when building a release (build types Release and RelWithDebInfo) with the Unix Makefile generator. Before it was tried to do this with all generators causing multiple problems. --- CMakeLists.txt | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a53898451..66be20c61 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -235,20 +235,7 @@ if(CMAKE_COMPILER_IS_GNUCC) endif() endif() if(CMAKE_BUILD_TYPE STREQUAL "Release") - set(FILE_SUBST "\"$(subst ${CMAKE_BINARY_DIR}/,,$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<)))\"") add_definitions(-DNDEBUG) - - CHECK_C_COMPILER_FLAG (-Wno-builtin-macro-redefined Wno-builtin-macro-redefined) - if(Wno-builtin-macro-redefined) - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wno-builtin-macro-redefined") - add_definitions("-D__FILE__=${FILE_SUBST}") - endif() - - CHECK_CXX_COMPILER_FLAG (-Wno-builtin-macro-redefined Wno-builtin-macro-redefinedCXX) - if(Wno-builtin-macro-redefinedCXX) - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-builtin-macro-redefined") - add_definitions("-D__FILE__=${FILE_SUBST}") - endif() else() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") @@ -258,6 +245,23 @@ if(CMAKE_COMPILER_IS_GNUCC) endif() endif() +# When building with Unix Makefiles and doing any release builds +# try to set __FILE__ to relative paths via a make specific macro +if (CMAKE_GENERATOR MATCHES "Unix Makefile*") + if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") + string(TOUPPER ${CMAKE_BUILD_TYPE} UPPER_BUILD_TYPE) + CHECK_C_COMPILER_FLAG (-Wno-builtin-macro-redefined Wno-builtin-macro-redefined) + if(Wno-builtin-macro-redefined) + set(CMAKE_C_FLAGS_${UPPER_BUILD_TYPE} "${CMAKE_C_FLAGS_${UPPER_BUILD_TYPE}} -Wno-builtin-macro-redefined -D__FILE__='\"$(subst ${CMAKE_BINARY_DIR}/,,$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<)))\"'") + endif() + + CHECK_CXX_COMPILER_FLAG (-Wno-builtin-macro-redefined Wno-builtin-macro-redefinedCXX) + if(Wno-builtin-macro-redefinedCXX) + set(CMAKE_CXX_FLAGS_${UPPER_BUILD_TYPE} "${CMAKE_CXX_FLAGS_${UPPER_BUILD_TYPE}} -Wno-builtin-macro-redefined -D__FILE__='\"$(subst ${CMAKE_BINARY_DIR}/,,$(subst ${CMAKE_SOURCE_DIR}/,,$(abspath $<)))\"'") + endif() + endif() +endif() + if(${CMAKE_C_COMPILER_ID} STREQUAL "Clang") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-macros -Wno-padded")