From 36a37cc7525175c18a35ac73734890268bdc9ae6 Mon Sep 17 00:00:00 2001 From: Scott Tsai Date: Fri, 27 Apr 2012 01:14:21 +0800 Subject: [PATCH 1/4] Use PULSEAUDIO_INCLUDE_DIR instead of PULSE_INCLUDE_DIRS --- channels/drdynvc/audin/pulse/CMakeLists.txt | 2 +- channels/drdynvc/tsmf/pulse/CMakeLists.txt | 2 +- channels/rdpsnd/pulse/CMakeLists.txt | 2 +- cmake/FindPulseAudio.cmake | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/channels/drdynvc/audin/pulse/CMakeLists.txt b/channels/drdynvc/audin/pulse/CMakeLists.txt index fd6e25ec3..c27f87068 100644 --- a/channels/drdynvc/audin/pulse/CMakeLists.txt +++ b/channels/drdynvc/audin/pulse/CMakeLists.txt @@ -22,7 +22,7 @@ set(AUDIN_PULSE_SRCS ) include_directories(..) -include_directories(${PULSE_INCLUDE_DIRS}) +include_directories(${PULSEAUDIO_INCLUDE_DIR}) add_library(audin_pulse ${AUDIN_PULSE_SRCS}) set_target_properties(audin_pulse PROPERTIES PREFIX "") diff --git a/channels/drdynvc/tsmf/pulse/CMakeLists.txt b/channels/drdynvc/tsmf/pulse/CMakeLists.txt index 144b5ffb3..ae137a555 100644 --- a/channels/drdynvc/tsmf/pulse/CMakeLists.txt +++ b/channels/drdynvc/tsmf/pulse/CMakeLists.txt @@ -22,7 +22,7 @@ set(TSMF_PULSE_SRCS ) include_directories(..) -include_directories(${PULSE_INCLUDE_DIRS}) +include_directories(${PULSEAUDIO_INCLUDE_DIR}) add_library(tsmf_pulse ${TSMF_PULSE_SRCS}) set_target_properties(tsmf_pulse PROPERTIES PREFIX "") diff --git a/channels/rdpsnd/pulse/CMakeLists.txt b/channels/rdpsnd/pulse/CMakeLists.txt index bac3e510a..844ffde4f 100644 --- a/channels/rdpsnd/pulse/CMakeLists.txt +++ b/channels/rdpsnd/pulse/CMakeLists.txt @@ -22,7 +22,7 @@ set(RDPSND_PULSE_SRCS ) include_directories(..) -include_directories(${PULSE_INCLUDE_DIRS}) +include_directories(${PULSEAUDIO_INCLUDE_DIR}) add_library(rdpsnd_pulse ${RDPSND_PULSE_SRCS}) set_target_properties(rdpsnd_pulse PROPERTIES PREFIX "") diff --git a/cmake/FindPulseAudio.cmake b/cmake/FindPulseAudio.cmake index 03d1c611b..3cf8e974c 100644 --- a/cmake/FindPulseAudio.cmake +++ b/cmake/FindPulseAudio.cmake @@ -4,7 +4,7 @@ if (PKG_CONFIG_FOUND) pkg_check_modules(PULSEAUDIO libpulse) endif() -find_path(PULSEAUDIO_INCLUDE_DIR pulseaudio.h PATHS ${PULSEAUDIO_INCLUDE_DIRS} PATH_SUFFIXES pulse ) +find_path(PULSEAUDIO_INCLUDE_DIR pulse/pulseaudio.h PATHS ${PULSEAUDIO_INCLUDE_DIRS} PATH_SUFFIXES pulse ) find_library(PULSEAUDIO_LIBRARY pulse PATHS ${PULSEAUDIO_LIBRARY_DIRS}) FIND_PACKAGE_HANDLE_STANDARD_ARGS(PulseAudio DEFAULT_MSG PULSEAUDIO_INCLUDE_DIR PULSEAUDIO_LIBRARY) From 7aa29e9e0b6fe5136b797b56ab9db91341634ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Rop=C3=A9?= Date: Fri, 4 May 2012 15:42:19 +0200 Subject: [PATCH 2/4] Added some comments to the plugin loading functions, for documentation purposes --- libfreerdp-utils/load_plugin.c | 67 ++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/libfreerdp-utils/load_plugin.c b/libfreerdp-utils/load_plugin.c index b9bae3b03..473640db1 100644 --- a/libfreerdp-utils/load_plugin.c +++ b/libfreerdp-utils/load_plugin.c @@ -46,6 +46,20 @@ #endif +/** + * UNUSED + * This function opens a handle on the specified library in order to load symbols from it. + * It is just a wrapper over dlopen(), but provides some logs in case of error. + * + * The returned pointer can be used to load a symbol from the library, using the freerdp_get_library_symbol() call. + * The returned pointer should be closed using the freerdp_close_library() call. + * + * @see freerdp_get_library_symbol + * @see freerdp_close_library + * + * @param file [IN] - library name + * @return Pointer to the loaded library. NULL if an error occurs. + */ void* freerdp_open_library(const char* file) { void* library; @@ -61,6 +75,20 @@ void* freerdp_open_library(const char* file) return library; } +/** + * UNUSED + * This function retrieves a pointer to the specified symbol from the given (loaded) library. + * It is a wrapper over the dlsym() function, but provides some logs in case of error. + * + * @see freerdp_open_library + * @see freerdp_close_library + * + * @param library [IN] - a valid pointer to the opened library. + * This pointer should come from a successful call to freerdp_open_library() + * @param name [IN] - name of the symbol that must be loaded + * + * @return A pointer to the loaded symbol. NULL if an error occured. + */ void* freerdp_get_library_symbol(void* library, const char* name) { void* symbol; @@ -76,6 +104,16 @@ void* freerdp_get_library_symbol(void* library, const char* name) return symbol; } +/** + * UNUSED + * This function closes a library handle that was previously opened by freerdp_open_library(). + * It is a wrapper over dlclose(), but provides logs in case of error. + * + * @see freerdp_open_library + * @see freerdp_get_library_symbol + * + * @return true if the close succeeded. false otherwise. + */ boolean freerdp_close_library(void* library) { int status; @@ -95,6 +133,17 @@ boolean freerdp_close_library(void* library) return true; } +/** + * This function will load the specified library, retrieve the specified symbol in it, and return a pointer to it. + * It is used in freerdp_load_plugin() and freerdp_load_channel_plugin(). + * It seems there is no way to unload the library once this call is made. Now since this is used for plugins, + * we probably don't need to take care of unloading them, as it will be done only at shutdown. + * + * @param file [IN] - library name + * @param name [IN] - symbol name to find in the library + * + * @return pointer to the referenced symbol. NULL if an error occured. + */ void* freerdp_load_library_symbol(const char* file, const char* name) { void* library; @@ -119,6 +168,17 @@ void* freerdp_load_library_symbol(const char* file, const char* name) return symbol; } +/** + * This function is used to load plugins. It will load the specified library, retrieve the specified symbol, + * and return a pointer to it. + * There is no way to unload the library once it has been loaded this way - since it is used for plugins only, + * maybe it's not a must. + * + * @param name [IN] - name of the library to load + * @param entry_name [IN] - name of the symbol to find and load from the library + * + * @return Pointer to the loaded symbol. NULL if an error occurred. + */ void* freerdp_load_plugin(const char* name, const char* entry_name) { char* path; @@ -152,6 +212,13 @@ void* freerdp_load_plugin(const char* name, const char* entry_name) return entry; } +/** + * UNUSED + * This function was meant to be used to load channel plugins. + * It was initially called from freerdp_channels_load_plugin() but now we use the freerdp_load_plugin() function + * which is more generic. + * + */ void* freerdp_load_channel_plugin(rdpSettings* settings, const char* name, const char* entry_name) { char* path; From c1f70446939226bd08f867a1dea8200f99a365c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Rop=C3=A9?= Date: Fri, 4 May 2012 15:50:33 +0200 Subject: [PATCH 3/4] Some fixes for potentials NULL pointer dereferences, and double-free of buffers --- channels/rdpdr/printer/printer_cups.c | 3 +-- client/X11/xfreerdp.c | 2 +- libfreerdp-channels/libchannels.c | 12 ++++++------ libfreerdp-channels/wtsvc.c | 4 +++- libfreerdp-crypto/tls.c | 3 +++ libfreerdp-sspi/Kerberos/kerberos_decode.c | 2 +- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/channels/rdpdr/printer/printer_cups.c b/channels/rdpdr/printer/printer_cups.c index 846cc31d8..1f0c58cc1 100644 --- a/channels/rdpdr/printer/printer_cups.c +++ b/channels/rdpdr/printer/printer_cups.c @@ -125,9 +125,8 @@ static void printer_cups_close_printjob(rdpPrintJob* printjob) #endif - xfree(cups_printjob); - ((rdpCupsPrinter*)printjob->printer)->printjob = NULL; + xfree(cups_printjob) ; } static rdpPrintJob* printer_cups_create_printjob(rdpPrinter* printer, uint32 id) diff --git a/client/X11/xfreerdp.c b/client/X11/xfreerdp.c index a9cc8c181..0b2ebe930 100644 --- a/client/X11/xfreerdp.c +++ b/client/X11/xfreerdp.c @@ -1180,7 +1180,7 @@ int xfreerdp_run(freerdp* instance) /** Entry point for the thread that will deal with the session. * It just calls xfreerdp_run() using the given instance as parameter. - * @param - pointer to a thread_data structure that contains the initialized connection. + * @param param - pointer to a thread_data structure that contains the initialized connection. */ void* thread_func(void* param) { diff --git a/libfreerdp-channels/libchannels.c b/libfreerdp-channels/libchannels.c index cb0a06b46..cd3083bc5 100644 --- a/libfreerdp-channels/libchannels.c +++ b/libfreerdp-channels/libchannels.c @@ -287,6 +287,12 @@ static uint32 FREERDP_CC MyVirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF PCHANNEL_DEF lchannel_def; struct channel_data* lchannel_data; + if (ppInitHandle == NULL) + { + DEBUG_CHANNELS("error bad pphan"); + return CHANNEL_RC_BAD_INIT_HANDLE; + } + channels = g_init_channels; channels->init_handles[channels->num_init_handles].channels = channels; *ppInitHandle = &channels->init_handles[channels->num_init_handles]; @@ -300,12 +306,6 @@ static uint32 FREERDP_CC MyVirtualChannelInit(void** ppInitHandle, PCHANNEL_DEF return CHANNEL_RC_NOT_IN_VIRTUALCHANNELENTRY; } - if (ppInitHandle == 0) - { - DEBUG_CHANNELS("error bad pphan"); - return CHANNEL_RC_BAD_INIT_HANDLE; - } - if (channels->num_channels_data + channelCount >= CHANNEL_MAX_COUNT) { DEBUG_CHANNELS("error too many channels"); diff --git a/libfreerdp-channels/wtsvc.c b/libfreerdp-channels/wtsvc.c index 03a91b4b7..6e3424d06 100644 --- a/libfreerdp-channels/wtsvc.c +++ b/libfreerdp-channels/wtsvc.c @@ -310,11 +310,13 @@ boolean WTSVirtualChannelWrite( wts_data_item* item; boolean result = false; rdpPeerChannel* channel = (rdpPeerChannel*) hChannelHandle; - WTSVirtualChannelManager* vcm = channel->vcm; + WTSVirtualChannelManager* vcm ; if (channel == NULL) return false; + vcm = channel->vcm ; + if (channel->channel_type == RDP_PEER_CHANNEL_TYPE_SVC) { item = xnew(wts_data_item); diff --git a/libfreerdp-crypto/tls.c b/libfreerdp-crypto/tls.c index 39ad75769..175106ba9 100644 --- a/libfreerdp-crypto/tls.c +++ b/libfreerdp-crypto/tls.c @@ -357,7 +357,10 @@ boolean tls_verify_certificate(rdpTls* tls, CryptoCert cert, char* hostname) if (certificate_status && hostname_match) { if (common_name) + { xfree(common_name); + common_name=NULL ; + } verification_status = true; /* success! */ } diff --git a/libfreerdp-sspi/Kerberos/kerberos_decode.c b/libfreerdp-sspi/Kerberos/kerberos_decode.c index 36011e13b..3f99d1fce 100644 --- a/libfreerdp-sspi/Kerberos/kerberos_decode.c +++ b/libfreerdp-sspi/Kerberos/kerberos_decode.c @@ -261,7 +261,7 @@ int krb_decode_cname(STREAM* s, uint8 tag, char** str) if(verlen != len) { - xfree(str); + xfree(*str); *str = NULL; goto err; } From 91d2a046f965d6548f2b4865d01493ffd51f9898 Mon Sep 17 00:00:00 2001 From: David Sundstrom Date: Fri, 4 May 2012 15:11:30 -0500 Subject: [PATCH 4/4] Fix Solaris 10 compilation issues. timezone.c: local variable 'timezone' shadowed global variable of same name memory.c wide-string copy function on Solaris 10 is 'wsdup' --- libfreerdp-locale/timezone.c | 18 +++++++++--------- libfreerdp-utils/memory.c | 2 ++ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/libfreerdp-locale/timezone.c b/libfreerdp-locale/timezone.c index b2891fb5e..e73efa4f7 100644 --- a/libfreerdp-locale/timezone.c +++ b/libfreerdp-locale/timezone.c @@ -1598,7 +1598,7 @@ void freerdp_time_zone_detect(TIME_ZONE_INFO* clientTimeZone) { time_t t; struct tm* local_time; - TIME_ZONE_ENTRY* timezone; + TIME_ZONE_ENTRY* tz; time(&t); local_time = localtime(&t); @@ -1628,18 +1628,18 @@ void freerdp_time_zone_detect(TIME_ZONE_INFO* clientTimeZone) clientTimeZone->daylightBias = clientTimeZone->bias + 60; } - timezone = freerdp_detect_windows_time_zone(clientTimeZone->bias); + tz = freerdp_detect_windows_time_zone(clientTimeZone->bias); - if (timezone != NULL) + if (tz!= NULL) { - clientTimeZone->bias = timezone->Bias; - sprintf(clientTimeZone->standardName, "%s", timezone->StandardName); - sprintf(clientTimeZone->daylightName, "%s", timezone->DaylightName); + clientTimeZone->bias = tz->Bias; + sprintf(clientTimeZone->standardName, "%s", tz->StandardName); + sprintf(clientTimeZone->daylightName, "%s", tz->DaylightName); - if ((timezone->SupportsDST) && (timezone->RuleTableCount > 0)) + if ((tz->SupportsDST) && (tz->RuleTableCount > 0)) { TIME_ZONE_RULE_ENTRY* rule; - rule = freerdp_get_current_time_zone_rule(timezone->RuleTable, timezone->RuleTableCount); + rule = freerdp_get_current_time_zone_rule(tz->RuleTable, tz->RuleTableCount); if (rule != NULL) { @@ -1666,7 +1666,7 @@ void freerdp_time_zone_detect(TIME_ZONE_INFO* clientTimeZone) } } - xfree(timezone); + xfree(tz); } else { diff --git a/libfreerdp-utils/memory.c b/libfreerdp-utils/memory.c index a4abc3cba..525772cef 100644 --- a/libfreerdp-utils/memory.c +++ b/libfreerdp-utils/memory.c @@ -141,6 +141,8 @@ wchar_t* xwcsdup(const wchar_t* wstr) #ifdef _WIN32 mem = _wcsdup(wstr); +#elif sun + mem = wsdup(wstr); #else mem = wcsdup(wstr); #endif