From 90e903957aa6e4dc96de5b410748d41dde74225d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benoi=CC=82t=20LeBlanc?= Date: Fri, 25 Oct 2013 14:59:38 -0400 Subject: [PATCH 01/10] Fixed warmings (string formats) --- libfreerdp/core/gateway/tsg.c | 2 +- libfreerdp/utils/profiler.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libfreerdp/core/gateway/tsg.c b/libfreerdp/core/gateway/tsg.c index e10e164c8..a1a477be6 100644 --- a/libfreerdp/core/gateway/tsg.c +++ b/libfreerdp/core/gateway/tsg.c @@ -355,7 +355,7 @@ BOOL TsProxyCreateTunnelReadResponse(rdpTsg* tsg, RPC_PDU* pdu) offset += 8; // UnicodeString Offset, Length } if(MsgBytes > TSG_MESSAGING_MAX_MESSAGE_LENGTH) { - fprintf(stderr, "Out of Spec Message Length %d"); + fprintf(stderr, "Out of Spec Message Length %d", MsgBytes); return FALSE; } offset += MsgBytes; diff --git a/libfreerdp/utils/profiler.c b/libfreerdp/utils/profiler.c index 794f3e7f1..d735dba77 100644 --- a/libfreerdp/utils/profiler.c +++ b/libfreerdp/utils/profiler.c @@ -70,7 +70,7 @@ void profiler_print(PROFILER* profiler) double elapsed_sec = stopwatch_get_elapsed_time_in_seconds(profiler->stopwatch); double avg_sec = elapsed_sec / (double) profiler->stopwatch->count; - fprintf(stderr, "| %-30.30s| %10lu | %9f | %9f |\n", + fprintf(stderr, "| %-30.30s| %10du | %9f | %9f |\n", profiler->name, profiler->stopwatch->count, elapsed_sec, avg_sec); } From ebb71062b84671946b35100d934b1d7027b08526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benoi=CC=82t=20LeBlanc?= Date: Mon, 28 Oct 2013 13:44:17 -0400 Subject: [PATCH 02/10] fixed incorrect printf format --- libfreerdp/crypto/tls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libfreerdp/crypto/tls.c b/libfreerdp/crypto/tls.c index e5c496b40..52bdaf712 100644 --- a/libfreerdp/crypto/tls.c +++ b/libfreerdp/crypto/tls.c @@ -99,7 +99,7 @@ SecPkgContext_Bindings* tls_get_channel_bindings(X509* cert) static void tls_ssl_info_callback(const SSL* ssl, int type, int val) { - printf("tls_ssl_info_callback: type: %d val: %d\n"); + printf("tls_ssl_info_callback: type: %d val: %d\n", type, val); if (type & SSL_CB_HANDSHAKE_START) { From 993f5f18b81a052ead96ce9e12d9a07fa08ebce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benoi=CC=82t=20LeBlanc?= Date: Mon, 4 Nov 2013 09:10:05 -0500 Subject: [PATCH 03/10] added const to buffer parameters in functions --- client/common/client.c | 2 +- client/common/file.c | 6 +++--- include/freerdp/client.h | 2 +- include/freerdp/client/file.h | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/common/client.c b/client/common/client.c index 926ea9889..b3b5a3617 100644 --- a/client/common/client.c +++ b/client/common/client.c @@ -133,7 +133,7 @@ int freerdp_client_settings_parse_connection_file(rdpSettings* settings, const c return 0; } -int freerdp_client_settings_parse_connection_file_buffer(rdpSettings* settings, BYTE* buffer, size_t size) +int freerdp_client_settings_parse_connection_file_buffer(rdpSettings* settings, const BYTE* buffer, size_t size) { rdpFile* file; int status = -1; diff --git a/client/common/file.c b/client/common/file.c index 35b0b1341..153325bb6 100644 --- a/client/common/file.c +++ b/client/common/file.c @@ -323,7 +323,7 @@ void freerdp_client_parse_rdp_file_option_ascii(rdpFile* file, char* option) freerdp_client_add_option(file, option); } -BOOL freerdp_client_parse_rdp_file_buffer_ascii(rdpFile* file, BYTE* buffer, size_t size) +BOOL freerdp_client_parse_rdp_file_buffer_ascii(rdpFile* file, const BYTE* buffer, size_t size) { int length; char* line; @@ -395,7 +395,7 @@ next_line: return TRUE; } -BOOL freerdp_client_parse_rdp_file_buffer_unicode(rdpFile* file, BYTE* buffer, size_t size) +BOOL freerdp_client_parse_rdp_file_buffer_unicode(rdpFile* file, const BYTE* buffer, size_t size) { int length; WCHAR* line; @@ -468,7 +468,7 @@ next_line: return TRUE; } -BOOL freerdp_client_parse_rdp_file_buffer(rdpFile* file, BYTE* buffer, size_t size) +BOOL freerdp_client_parse_rdp_file_buffer(rdpFile* file, const BYTE* buffer, size_t size) { if (size < 2) return FALSE; diff --git a/include/freerdp/client.h b/include/freerdp/client.h index 2878ffa2e..60ada2772 100644 --- a/include/freerdp/client.h +++ b/include/freerdp/client.h @@ -87,7 +87,7 @@ FREERDP_API HANDLE freerdp_client_get_thread(rdpContext* context); FREERDP_API int freerdp_client_settings_parse_command_line(rdpSettings* settings, int argc, char** argv); FREERDP_API int freerdp_client_settings_parse_connection_file(rdpSettings* settings, const char* filename); -FREERDP_API int freerdp_client_settings_parse_connection_file_buffer(rdpSettings* settings, BYTE* buffer, size_t size); +FREERDP_API int freerdp_client_settings_parse_connection_file_buffer(rdpSettings* settings, const BYTE* buffer, size_t size); FREERDP_API int freerdp_client_settings_write_connection_file(rdpSettings* settings, const char* filename, BOOL unicode); #ifdef __cplusplus diff --git a/include/freerdp/client/file.h b/include/freerdp/client/file.h index bf9dcb4d6..8268f286d 100644 --- a/include/freerdp/client/file.h +++ b/include/freerdp/client/file.h @@ -142,7 +142,7 @@ extern "C" { #endif FREERDP_API BOOL freerdp_client_parse_rdp_file(rdpFile* file, const char* name); -FREERDP_API BOOL freerdp_client_parse_rdp_file_buffer(rdpFile* file, BYTE* buffer, size_t size); +FREERDP_API BOOL freerdp_client_parse_rdp_file_buffer(rdpFile* file, const BYTE* buffer, size_t size); FREERDP_API BOOL freerdp_client_populate_settings_from_rdp_file(rdpFile* file, rdpSettings* settings); FREERDP_API BOOL freerdp_client_populate_rdp_file_from_settings(rdpFile* file, rdpSettings* settings); From cc881678a67e65cc3063e2d6d83809ba04997484 Mon Sep 17 00:00:00 2001 From: Richard Markiewicz Date: Mon, 4 Nov 2013 11:35:25 -0500 Subject: [PATCH 04/10] Update AppDelegate.m stringWithFormat returns an autoreleased object, so manually releasing message results in a crash --- client/Mac/cli/AppDelegate.m | 1 - 1 file changed, 1 deletion(-) diff --git a/client/Mac/cli/AppDelegate.m b/client/Mac/cli/AppDelegate.m index 9c5636079..612205bae 100644 --- a/client/Mac/cli/AppDelegate.m +++ b/client/Mac/cli/AppDelegate.m @@ -199,7 +199,6 @@ void AppDelegate_ConnectionResultEventHandler(void* ctx, ConnectionResultEventAr // Making sure this should be invoked on the main UI thread. [_singleDelegate performSelectorOnMainThread:@selector(rdpConnectError:) withObject:message waitUntilDone:FALSE]; - [message release]; } } } From 08da7211aa05c182e31bf4a2a912f7c79d223e04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benoi=CC=82t=20LeBlanc?= Date: Wed, 6 Nov 2013 20:07:42 -0500 Subject: [PATCH 05/10] Fixed crash caused by string value not being copied when parsing an ASCII file. --- client/common/file.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/common/file.c b/client/common/file.c index 341c1222d..fd4729828 100644 --- a/client/common/file.c +++ b/client/common/file.c @@ -305,7 +305,9 @@ void freerdp_client_parse_rdp_file_string_unicode(rdpFile* file, WCHAR* name, WC void freerdp_client_parse_rdp_file_string_ascii(rdpFile* file, char* name, char* value) { - freerdp_client_rdp_file_set_string(file, name, value); + char* valueA = _strdup(value); + if (!freerdp_client_rdp_file_set_string(file, name, valueA)) + free(valueA); } void freerdp_client_parse_rdp_file_option_unicode(rdpFile* file, WCHAR* option) @@ -325,6 +327,7 @@ void freerdp_client_parse_rdp_file_option_ascii(rdpFile* file, char* option) BOOL freerdp_client_parse_rdp_file_buffer_ascii(rdpFile* file, const BYTE* buffer, size_t size) { + fprintf(stderr, "freerdp_client_parse_rdp_file_buffer_ascii"); int length; char* line; char* type; @@ -397,6 +400,7 @@ next_line: BOOL freerdp_client_parse_rdp_file_buffer_unicode(rdpFile* file, const BYTE* buffer, size_t size) { + fprintf(stderr, "freerdp_client_parse_rdp_file_buffer_unicode\n"); int length; WCHAR* line; WCHAR* type; From b50969e05df438087d629cdfd8b8c2cf8eb2347f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benoi=CC=82t=20LeBlanc?= Date: Wed, 6 Nov 2013 20:15:14 -0500 Subject: [PATCH 06/10] Removed logs --- client/common/file.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/client/common/file.c b/client/common/file.c index fd4729828..e979d4c9a 100644 --- a/client/common/file.c +++ b/client/common/file.c @@ -327,7 +327,6 @@ void freerdp_client_parse_rdp_file_option_ascii(rdpFile* file, char* option) BOOL freerdp_client_parse_rdp_file_buffer_ascii(rdpFile* file, const BYTE* buffer, size_t size) { - fprintf(stderr, "freerdp_client_parse_rdp_file_buffer_ascii"); int length; char* line; char* type; @@ -400,7 +399,6 @@ next_line: BOOL freerdp_client_parse_rdp_file_buffer_unicode(rdpFile* file, const BYTE* buffer, size_t size) { - fprintf(stderr, "freerdp_client_parse_rdp_file_buffer_unicode\n"); int length; WCHAR* line; WCHAR* type; From f4d0371480c85aa945b126203604cffcf3a9ed5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benoi=CC=82t=20LeBlanc?= Date: Thu, 7 Nov 2013 10:48:49 -0500 Subject: [PATCH 07/10] Removed const warning --- client/common/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/common/file.c b/client/common/file.c index 11352d515..40240892d 100644 --- a/client/common/file.c +++ b/client/common/file.c @@ -633,7 +633,7 @@ BOOL freerdp_client_write_rdp_file(const rdpFile* file, const char* name, BOOL u } #define WRITE_RDP_FILE_DECLARE(_file, _buffer, _size) \ - rdpFile* __rdpFile = file; \ + const rdpFile* __rdpFile = file; \ char* __buffer = _buffer; \ size_t __size = _size; \ size_t __required_size = 0; \ From c4dea17af33be0ff8d24fe12536cca59f29b14ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20LeBlanc?= Date: Thu, 7 Nov 2013 13:44:18 -0500 Subject: [PATCH 08/10] added _scprintf macro to winpr because snprintf does not count characters on Windows. Modified write_rdp_file_ macros for windows compatibility --- client/common/file.c | 12 ++++++++++-- winpr/include/winpr/string.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/client/common/file.c b/client/common/file.c index 40240892d..b7787d096 100644 --- a/client/common/file.c +++ b/client/common/file.c @@ -643,7 +643,11 @@ BOOL freerdp_client_write_rdp_file(const rdpFile* file, const char* name, BOOL u #define WRITE_RDP_FILE_VALUE_INTEGER(_format, _field) \ if (~__rdpFile->_field) \ { \ - __count = sprintf_s(__buffer == NULL ? NULL : __buffer + __current, __buffer == NULL ? 0 : __size - __required_size, _format, (int) __rdpFile->_field); \ + if (__buffer) \ + __count = sprintf_s(__buffer + __current, __size - __required_size, _format, (int) __rdpFile->_field); \ + else \ + __count = _scprintf(_format, (int) __rdpFile->_field); \ + \ __required_size += __count; \ __current += __count; \ } @@ -651,7 +655,11 @@ if (~__rdpFile->_field) \ #define WRITE_RDP_FILE_VALUE_STRING(_format, _field) \ if (~((size_t) __rdpFile->_field) && __rdpFile->_field != NULL) \ { \ - __count = sprintf_s(__buffer == NULL ? NULL : __buffer + __current, __buffer == NULL ? 0 : __size - __required_size, _format, __rdpFile->_field); \ + if (buffer) \ + __count = sprintf_s(__buffer + __current, __size - __required_size, _format, __rdpFile->_field); \ + else \ + __count = _scprintf(_format, __rdpFile->_field); \ + \ __required_size += __count; \ __current += __count; \ } diff --git a/winpr/include/winpr/string.h b/winpr/include/winpr/string.h index 8cb2466f0..65cdc5549 100644 --- a/winpr/include/winpr/string.h +++ b/winpr/include/winpr/string.h @@ -153,6 +153,7 @@ WINPR_API int lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2); #endif #define sprintf_s snprintf +#define _scprintf(_fmt, …) snprintf(NULL, 0, _fmt, ## __VAR_ARGS__) /* Unicode Conversion */ From 02fe384ecb4d2ced6ca70fb3fb77fd1eca17fa3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20LeBlanc?= Date: Thu, 7 Nov 2013 13:45:16 -0500 Subject: [PATCH 09/10] typo --- client/common/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/common/file.c b/client/common/file.c index b7787d096..0d993345e 100644 --- a/client/common/file.c +++ b/client/common/file.c @@ -655,7 +655,7 @@ if (~__rdpFile->_field) \ #define WRITE_RDP_FILE_VALUE_STRING(_format, _field) \ if (~((size_t) __rdpFile->_field) && __rdpFile->_field != NULL) \ { \ - if (buffer) \ + if (__buffer) \ __count = sprintf_s(__buffer + __current, __size - __required_size, _format, __rdpFile->_field); \ else \ __count = _scprintf(_format, __rdpFile->_field); \ From dfd39b6d0a8c16c658f5ccfbc6055b08126104b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benoi=CC=82t=20LeBlanc?= Date: Thu, 7 Nov 2013 13:55:06 -0500 Subject: [PATCH 10/10] Fixed macro declaration --- winpr/include/winpr/string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winpr/include/winpr/string.h b/winpr/include/winpr/string.h index 65cdc5549..d35728b1d 100644 --- a/winpr/include/winpr/string.h +++ b/winpr/include/winpr/string.h @@ -153,7 +153,7 @@ WINPR_API int lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2); #endif #define sprintf_s snprintf -#define _scprintf(_fmt, …) snprintf(NULL, 0, _fmt, ## __VAR_ARGS__) +#define _scprintf(_fmt, ...) snprintf(NULL, 0, _fmt, ## __VA_ARGS__) /* Unicode Conversion */