From 2601d110aa7b24da5d5ecffe25f7e0ed84fbd8dc Mon Sep 17 00:00:00 2001 From: Brad Hards Date: Wed, 27 Jul 2011 09:14:11 +1000 Subject: [PATCH 1/5] Various minor warning fixes and unittest fixes. --- channels/drdynvc/drdynvc_main.c | 6 ++---- channels/drdynvc/dvcman.c | 4 ++-- client/test/freerdp.c | 10 +++++----- cunit/CMakeLists.txt | 1 + cunit/test_ber.c | 3 ++- cunit/test_bitmap.c | 1 + cunit/test_chanman.c | 2 +- cunit/test_cliprdr.c | 4 ++-- cunit/test_drdynvc.c | 3 +-- cunit/test_freerdp.c | 1 - cunit/test_gcc.c | 3 +++ cunit/test_per.c | 1 + cunit/test_transport.c | 4 ++-- cunit/test_utils.h | 6 +++--- include/freerdp/dvc.h | 2 +- include/freerdp/freerdp.h | 4 ++-- include/freerdp/settings.h | 20 +++++++++---------- libfreerdp-core/ber.c | 1 + libfreerdp-core/capabilities.c | 4 ---- libfreerdp-core/certificate.c | 1 - libfreerdp-core/connection.c | 1 + libfreerdp-core/gcc.c | 8 +++----- libfreerdp-core/info.c | 19 +++++++++--------- libfreerdp-core/license.c | 11 +++-------- libfreerdp-core/mcs.c | 2 ++ libfreerdp-core/mcs.h | 2 ++ libfreerdp-core/nego.c | 5 +---- libfreerdp-core/per.c | 4 +--- libfreerdp-core/per.h | 2 ++ libfreerdp-core/rdp.c | 4 ++++ libfreerdp-core/registry.c | 35 +++++++++++++++++---------------- libfreerdp-core/registry.h | 8 ++++---- libfreerdp-core/security.c | 10 +++++----- libfreerdp-core/security.h | 3 --- libfreerdp-core/settings.c | 2 +- libfreerdp-core/tcp.c | 8 +++++--- libfreerdp-core/tcp.h | 6 +++--- libfreerdp-core/transport.c | 2 +- libfreerdp-core/transport.h | 2 +- libfreerdp-core/update.c | 1 + libfreerdp-utils/args.c | 14 ++++++------- 41 files changed, 114 insertions(+), 116 deletions(-) diff --git a/channels/drdynvc/drdynvc_main.c b/channels/drdynvc/drdynvc_main.c index c1b3a6061..d482435a4 100644 --- a/channels/drdynvc/drdynvc_main.c +++ b/channels/drdynvc/drdynvc_main.c @@ -75,8 +75,7 @@ static int drdynvc_write_variable_uint(STREAM* stream, uint32 val) int drdynvc_write_data(drdynvcPlugin* drdynvc, uint32 ChannelId, char* data, uint32 data_size) { STREAM* data_out; - uint32 pos; - uint32 t; + uint32 pos = 0; uint32 cbChId; uint32 cbLen; uint32 chunk_len; @@ -209,7 +208,7 @@ static int drdynvc_process_create_request(drdynvcPlugin* drdynvc, int Sp, int cb pos = stream_get_pos(data_in); DEBUG_DVC("ChannelId=%d ChannelName=%s", ChannelId, stream_get_tail(data_in)); - error = dvcman_create_channel(drdynvc->channel_mgr, ChannelId, stream_get_tail(data_in)); + error = dvcman_create_channel(drdynvc->channel_mgr, ChannelId, (char*)stream_get_tail(data_in)); data_out = stream_new(pos + 4); stream_write_uint8(data_out, 0x10 | cbChId); @@ -271,7 +270,6 @@ static int drdynvc_process_data(drdynvcPlugin* drdynvc, int Sp, int cbChId, STRE static int drdynvc_process_close_request(drdynvcPlugin* drdynvc, int Sp, int cbChId, STREAM* data_in) { - int pos; uint32 ChannelId; ChannelId = drdynvc_read_variable_uint(data_in, cbChId); diff --git a/channels/drdynvc/dvcman.c b/channels/drdynvc/dvcman.c index 098922c6c..536473b64 100644 --- a/channels/drdynvc/dvcman.c +++ b/channels/drdynvc/dvcman.c @@ -318,8 +318,8 @@ int dvcman_create_channel(IWTSVirtualChannelManager* pChannelMgr, uint32 Channel if (listener->listener_callback->OnNewChannelConnection(listener->listener_callback, (IWTSVirtualChannel*)channel, NULL, &bAccept, &pCallback) == 0 && bAccept == 1) { - DEBUG_PRINT("DVC", "listener %s created new channel %d", - listener->channel_name, channel->channel_id); + DEBUG_DVC("listener %s created new channel %d", + listener->channel_name, channel->channel_id); channel->channel_callback = pCallback; dvcman_channel_list_add(dvcman->channels, item); return 0; diff --git a/client/test/freerdp.c b/client/test/freerdp.c index 7dd6a5def..44cff14d9 100644 --- a/client/test/freerdp.c +++ b/client/test/freerdp.c @@ -34,7 +34,7 @@ } while(0) #define STRING_COPY(_str) do { \ - settings->_str = (uint8*) xmalloc(strlen(argv[*i])); \ + settings->_str = xmalloc(strlen(argv[*i])); \ memcpy(settings->_str, argv[*i], strlen(argv[*i])); \ settings->_str[strlen(argv[*i])] = '\0'; \ } while(0) @@ -145,10 +145,10 @@ boolean freerdp_process_params(int argc, char* argv[], rdpSettings* settings, in && (p[1] == 0 || (p[1] == ':' && !strchr(p + 2, ':')))) { /* Either "[...]" or "[...]:..." with at most one : after the brackets */ - settings->hostname = (uint8*) xmalloc(strlen(argv[*i] + 1)); + settings->hostname = (char*) xmalloc(strlen(argv[*i] + 1)); strncpy(settings->hostname, argv[*i] + 1, strlen(argv[*i] + 1)); - if ((p = strchr(settings->hostname, ']'))) + if ((p = strchr((const char*)settings->hostname, ']'))) { *p = 0; if (p[1] == ':') @@ -158,10 +158,10 @@ boolean freerdp_process_params(int argc, char* argv[], rdpSettings* settings, in else { /* Port number is cut off and used if exactly one : in the string */ - settings->hostname = (uint8*) xmalloc(strlen(argv[*i])); + settings->hostname = (char*) xmalloc(strlen(argv[*i])); strncpy(settings->hostname, argv[*i], strlen(argv[*i])); - if ((p = strchr(settings->hostname, ':')) && !strchr(p + 1, ':')) + if ((p = strchr((const char*)settings->hostname, ':')) && !strchr(p + 1, ':')) { *p = 0; settings->port = (uint16) atoi(p + 1); diff --git a/cunit/CMakeLists.txt b/cunit/CMakeLists.txt index 10798c64b..0785bac89 100644 --- a/cunit/CMakeLists.txt +++ b/cunit/CMakeLists.txt @@ -18,6 +18,7 @@ # limitations under the License. include_directories(${CUNIT_INCLUDE_DIRS}) +include_directories(${CMAKE_SOURCE_DIR}) # for some internal tests include_directories(../libfreerdp-core) include_directories(../libfreerdp-gdi) diff --git a/cunit/test_ber.c b/cunit/test_ber.c index 19ec7460c..378ccc086 100644 --- a/cunit/test_ber.c +++ b/cunit/test_ber.c @@ -22,6 +22,7 @@ #include #include "test_ber.h" +#include "libfreerdp-core/ber.h" int init_ber_suite(void) { @@ -72,7 +73,7 @@ void test_ber_write_universal_tag(void) STREAM* s; s = stream_new(sizeof(ber_universal_tag_expected)); - ber_write_universal_tag(s, 1); + ber_write_universal_tag(s, 1, False); ASSERT_STREAM(s, (uint8*) ber_universal_tag_expected, sizeof(ber_universal_tag_expected)); diff --git a/cunit/test_bitmap.c b/cunit/test_bitmap.c index f8eeb9d37..599175257 100644 --- a/cunit/test_bitmap.c +++ b/cunit/test_bitmap.c @@ -20,6 +20,7 @@ #include #include #include +#include "libfreerdp-core/bitmap.h" #include "test_bitmap.h" diff --git a/cunit/test_chanman.c b/cunit/test_chanman.c index 7ad61c034..9474f4581 100644 --- a/cunit/test_chanman.c +++ b/cunit/test_chanman.c @@ -48,7 +48,7 @@ int add_chanman_suite(void) return 0; } -static int test_rdp_channel_data(rdpInst* inst, int chan_id, char* data, int data_size) +static int test_rdp_channel_data(rdpInst* inst, int chan_id, uint8* data, int data_size) { printf("chan_id %d data_size %d\n", chan_id, data_size); } diff --git a/cunit/test_cliprdr.c b/cunit/test_cliprdr.c index 52791d88b..f8fa3d942 100644 --- a/cunit/test_cliprdr.c +++ b/cunit/test_cliprdr.c @@ -86,7 +86,7 @@ static const uint8 test_data_response_data[] = "\x6F\x00\x20\x00\x77\x00\x6F\x00\x72\x00\x6c\x00\x64\x00\x00\x00" }; -static int test_rdp_channel_data(rdpInst* inst, int chan_id, char* data, int data_size) +static int test_rdp_channel_data(rdpInst* inst, int chan_id, uint8* data, int data_size) { printf("chan_id %d data_size %d\n", chan_id, data_size); freerdp_hexdump(data, data_size); @@ -198,7 +198,7 @@ void test_cliprdr(void) event = freerdp_event_new(FRDP_EVENT_TYPE_CB_DATA_RESPONSE, event_process_callback, NULL); data_response_event = (FRDP_CB_DATA_RESPONSE_EVENT*)event; data_response_event->data = (uint8*)xmalloc(6); - strcpy(data_response_event->data, "hello"); + strcpy((char*)data_response_event->data, "hello"); data_response_event->size = 6; event_processed = 0; freerdp_chanman_send_event(chan_man, "cliprdr", event); diff --git a/cunit/test_drdynvc.c b/cunit/test_drdynvc.c index 9eec39ac3..be356228b 100644 --- a/cunit/test_drdynvc.c +++ b/cunit/test_drdynvc.c @@ -57,7 +57,7 @@ static const uint8 test_capability_request_data[] = static int data_received = 0; -static int test_rdp_channel_data(rdpInst* inst, int chan_id, char* data, int data_size) +static int test_rdp_channel_data(rdpInst* inst, int chan_id, uint8* data, int data_size) { printf("chan_id %d data_size %d\n", chan_id, data_size); freerdp_hexdump(data, data_size); @@ -69,7 +69,6 @@ void test_drdynvc(void) rdpChanMan* chan_man; rdpSettings settings = { 0 }; rdpInst inst = { 0 }; - int i; settings.hostname = "testhost"; inst.settings = &settings; diff --git a/cunit/test_freerdp.c b/cunit/test_freerdp.c index 7808e671b..cbd4ee12d 100644 --- a/cunit/test_freerdp.c +++ b/cunit/test_freerdp.c @@ -65,7 +65,6 @@ void dump_data(unsigned char * p, int len, int width, char* name) void assert_stream(STREAM* s, uint8* data, int length, const char* func, int line) { int i; - char* str; int actual_length; uint8* actual_data; diff --git a/cunit/test_gcc.c b/cunit/test_gcc.c index 929bcb8a7..7762b7452 100644 --- a/cunit/test_gcc.c +++ b/cunit/test_gcc.c @@ -134,6 +134,8 @@ void test_gcc_write_client_core_data(void) settings->rdp_version = 5; settings->color_depth = 24; settings->kbd_layout = 0x409; + settings->kbd_type = 0x04; + settings->kbd_fn_keys = 12; settings->client_build = 3790; strcpy(settings->client_hostname, "ELTONS-DEV2"); strcpy(settings->client_product_id, "69712-783-0357974-42714"); @@ -154,6 +156,7 @@ void test_gcc_write_client_security_data(void) s = stream_new(12); settings = settings_new(); + settings->encryption = 1; /* turn on encryption */ settings->encryption_method = ENCRYPTION_METHOD_40BIT | ENCRYPTION_METHOD_56BIT | diff --git a/cunit/test_per.c b/cunit/test_per.c index ad8392b82..45a545112 100644 --- a/cunit/test_per.c +++ b/cunit/test_per.c @@ -22,6 +22,7 @@ #include #include "test_per.h" +#include "libfreerdp-core/per.h" int init_per_suite(void) { diff --git a/cunit/test_transport.c b/cunit/test_transport.c index f947667e5..102ad87a2 100644 --- a/cunit/test_transport.c +++ b/cunit/test_transport.c @@ -56,20 +56,20 @@ int add_transport_suite(void) return 0; } +#if 0 static int test_finished = 0; static int packet_received(rdpTransport * transport, STREAM * stream, void * extra) { -#if 0 uint16 length; length = tpkt_read_header(stream); CU_ASSERT(length == 19); freerdp_hexdump(stream->data, length); test_finished = 1; return 0; -#endif } +#endif void test_transport(void) { diff --git a/cunit/test_utils.h b/cunit/test_utils.h index f0d4819b6..dcef6ac16 100644 --- a/cunit/test_utils.h +++ b/cunit/test_utils.h @@ -19,9 +19,9 @@ #include "test_freerdp.h" -int init_list_suite(void); -int clean_list_suite(void); -int add_list_suite(void); +int init_utils_suite(void); +int clean_utils_suite(void); +int add_utils_suite(void); void test_mutex(void); void test_semaphore(void); diff --git a/include/freerdp/dvc.h b/include/freerdp/dvc.h index fcb5373b8..51d394517 100644 --- a/include/freerdp/dvc.h +++ b/include/freerdp/dvc.h @@ -128,7 +128,7 @@ struct _IWTSVirtualChannelCallback /* Notifies the user about data that is being received. */ int (*OnDataReceived) (IWTSVirtualChannelCallback* pChannelCallback, uint32 cbSize, - char* pBuffer); + uint8* pBuffer); /* Notifies the user that the channel has been closed. */ int (*OnClose) (IWTSVirtualChannelCallback* pChannelCallback); }; diff --git a/include/freerdp/freerdp.h b/include/freerdp/freerdp.h index b98c050f0..e611c248d 100644 --- a/include/freerdp/freerdp.h +++ b/include/freerdp/freerdp.h @@ -54,8 +54,8 @@ struct rdp_inst int (* rdp_send_input_unicode)(rdpInst * inst, uint16 character); int (* rdp_send_input_mouse)(rdpInst * inst, uint16 pointerFlags, uint16 xPos, uint16 yPos); int (* rdp_sync_input)(rdpInst * inst, int toggle_flags); - int (* rdp_channel_data)(rdpInst * inst, int chan_id, char * data, int data_size); - void (*rdp_suppress_output)(rdpInst * inst, int allow_display_updates); + int (* rdp_channel_data)(rdpInst * inst, int chan_id, uint8 * data, int data_size); + void (* rdp_suppress_output)(rdpInst * inst, int allow_display_updates); void (* rdp_disconnect)(rdpInst * inst); int (* rdp_send_frame_ack)(rdpInst * inst, int frame_id); /* calls from library to ui */ diff --git a/include/freerdp/settings.h b/include/freerdp/settings.h index fcff17a82..41ff72c45 100644 --- a/include/freerdp/settings.h +++ b/include/freerdp/settings.h @@ -69,10 +69,10 @@ typedef struct typedef struct { uint32 bias; - uint8 standardName[32]; + char standardName[32]; SYSTEM_TIME standardDate; uint32 standardBias; - uint8 daylightName[32]; + char daylightName[32]; SYSTEM_TIME daylightDate; uint32 daylightBias; } TIME_ZONE_INFORMATION; @@ -153,20 +153,20 @@ struct rdp_settings char client_product_id[32]; uint16 port; - uint8* hostname; - uint8* username; - uint8* password; - uint8* domain; - uint8* shell; - uint8* directory; + char* hostname; + char* username; + char* password; + char* domain; + char* shell; + char* directory; uint32 performance_flags; boolean autologon; boolean compression; boolean ipv6; - uint8* ip_address; - uint8* client_dir; + char* ip_address; + char* client_dir; TIME_ZONE_INFORMATION client_time_zone; boolean auto_reconnection; diff --git a/libfreerdp-core/ber.c b/libfreerdp-core/ber.c index 316574626..ac05fada0 100644 --- a/libfreerdp-core/ber.c +++ b/libfreerdp-core/ber.c @@ -100,6 +100,7 @@ boolean ber_read_universal_tag(STREAM* s, uint8 tag, boolean pc) * Write BER Universal tag. * @param s stream * @param tag BER universally-defined tag + * @param pc primitive (False) or constructed (True) */ void ber_write_universal_tag(STREAM* s, uint8 tag, boolean pc) diff --git a/libfreerdp-core/capabilities.c b/libfreerdp-core/capabilities.c index 49e7b7ed0..2485defab 100644 --- a/libfreerdp-core/capabilities.c +++ b/libfreerdp-core/capabilities.c @@ -795,8 +795,6 @@ void rdp_write_glyph_cache_capability_set(STREAM* s, rdpSettings* settings) void rdp_read_offscreen_bitmap_cache_capability_set(STREAM* s, rdpSettings* settings) { uint32 offscreenSupportLevel; - uint16 offscreenCacheSize; - uint16 offscreenCacheEntries; stream_read_uint32(s, offscreenSupportLevel); /* offscreenSupportLevel (4 bytes) */ stream_read_uint16(s, settings->offscreen_bitmap_cache_size); /* offscreenCacheSize (2 bytes) */ @@ -977,8 +975,6 @@ void rdp_write_virtual_channel_capability_set(STREAM* s, rdpSettings* settings) void rdp_read_draw_nine_grid_cache_capability_set(STREAM* s, rdpSettings* settings) { uint32 drawNineGridSupportLevel; - uint16 drawNineGridCacheSize; - uint16 drawNineGridCacheEntries; stream_read_uint32(s, drawNineGridSupportLevel); /* drawNineGridSupportLevel (4 bytes) */ stream_read_uint16(s, settings->draw_nine_grid_cache_size); /* drawNineGridCacheSize (2 bytes) */ diff --git a/libfreerdp-core/certificate.c b/libfreerdp-core/certificate.c index e2b2b4c40..113af3cf5 100644 --- a/libfreerdp-core/certificate.c +++ b/libfreerdp-core/certificate.c @@ -119,7 +119,6 @@ void certificate_read_x509_certificate(CERT_BLOB* cert, CERT_INFO* info) int length; uint8 padding; uint32 version; - uint8 exponent[4]; int modulus_length; int exponent_length; diff --git a/libfreerdp-core/connection.c b/libfreerdp-core/connection.c index 17c393069..c9b3ff6e9 100644 --- a/libfreerdp-core/connection.c +++ b/libfreerdp-core/connection.c @@ -18,6 +18,7 @@ */ #include "connection.h" +#include "info.h" /** * Connection Sequence diff --git a/libfreerdp-core/gcc.c b/libfreerdp-core/gcc.c index 7b8bebeb8..b97ff2c37 100644 --- a/libfreerdp-core/gcc.c +++ b/libfreerdp-core/gcc.c @@ -144,7 +144,7 @@ void gcc_write_conference_create_request(STREAM* s, STREAM* user_data) per_write_selection(s, 0x08); /* select optional userData from ConferenceCreateRequest */ /* ConferenceCreateRequest::conferenceName */ - per_write_numeric_string(s, "1", 1, 1); /* ConferenceName::numeric */ + per_write_numeric_string(s, (uint8*)"1", 1, 1); /* ConferenceName::numeric */ per_write_padding(s, 1); /* padding */ /* UserData (SET OF SEQUENCE) */ @@ -165,7 +165,6 @@ void gcc_read_conference_create_response(STREAM* s, rdpSettings* settings) uint16 nodeID; uint8 result; uint8 choice; - uint8 selection; uint8 number; /* ConnectData */ @@ -272,13 +271,13 @@ void gcc_write_user_data_header(STREAM* s, uint16 type, uint16 length) void gcc_write_client_core_data(STREAM* s, rdpSettings *settings) { uint32 version; - uint8* clientName; + char* clientName; size_t clientNameLength; uint8 connectionType; uint16 highColorDepth; uint16 supportedColorDepths; uint16 earlyCapabilityFlags; - uint8* clientDigProductId; + char* clientDigProductId; size_t clientDigProductIdLength; gcc_write_user_data_header(s, CS_CORE, 216); @@ -319,7 +318,6 @@ void gcc_write_client_core_data(STREAM* s, rdpSettings *settings) highColorDepth = MIN(settings->color_depth, 24); supportedColorDepths = - RNS_UD_32BPP_SUPPORT | RNS_UD_24BPP_SUPPORT | RNS_UD_16BPP_SUPPORT | RNS_UD_15BPP_SUPPORT; diff --git a/libfreerdp-core/info.c b/libfreerdp-core/info.c index dcded8115..aad89ca38 100644 --- a/libfreerdp-core/info.c +++ b/libfreerdp-core/info.c @@ -117,10 +117,10 @@ void rdp_write_client_time_zone(STREAM* s, rdpSettings* settings) rdp_get_client_time_zone(s, settings); clientTimeZone = &settings->client_time_zone; - standardName = freerdp_uniconv_out(settings->uniconv, clientTimeZone->standardName, &length); + standardName = (uint8*)freerdp_uniconv_out(settings->uniconv, clientTimeZone->standardName, &length); standardNameLength = length; - daylightName = freerdp_uniconv_out(settings->uniconv, clientTimeZone->daylightName, &length); + daylightName = (uint8*)freerdp_uniconv_out(settings->uniconv, clientTimeZone->daylightName, &length); daylightNameLength = length; if (standardNameLength > 62) @@ -204,10 +204,10 @@ void rdp_write_extended_info_packet(STREAM* s, rdpSettings* settings) clientAddressFamily = settings->ipv6 ? ADDRESS_FAMILY_INET6 : ADDRESS_FAMILY_INET; - clientAddress = freerdp_uniconv_out(settings->uniconv, settings->ip_address, &length); + clientAddress = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->ip_address, &length); cbClientAddress = length; - clientDir = freerdp_uniconv_out(settings->uniconv, settings->client_dir, &length); + clientDir = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->client_dir, &length); cbClientDir = length; cbAutoReconnectLen = settings->client_auto_reconnect_cookie.cbLen; @@ -283,19 +283,19 @@ void rdp_write_info_packet(STREAM* s, rdpSettings* settings) if (settings->compression) flags |= INFO_COMPRESSION | PACKET_COMPR_TYPE_64K; - domain = freerdp_uniconv_out(settings->uniconv, settings->domain, &length); + domain = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->domain, &length); cbDomain = length; - userName = freerdp_uniconv_out(settings->uniconv, settings->username, &length); + userName = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->username, &length); cbUserName = length; - password = freerdp_uniconv_out(settings->uniconv, settings->password, &length); + password = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->password, &length); cbPassword = length; - alternateShell = freerdp_uniconv_out(settings->uniconv, settings->shell, &length); + alternateShell = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->shell, &length); cbAlternateShell = length; - workingDir = freerdp_uniconv_out(settings->uniconv, settings->directory, &length); + workingDir = (uint8*)freerdp_uniconv_out(settings->uniconv, settings->directory, &length); cbWorkingDir = length; stream_write_uint32(s, 0); /* CodePage */ @@ -397,7 +397,6 @@ void rdp_recv_logon_error_info(rdpRdp* rdp, STREAM* s) void rdp_recv_logon_info_extended(rdpRdp* rdp, STREAM* s) { - uint8* m; uint32 cbFieldData; uint32 fieldsPresent; diff --git a/libfreerdp-core/license.c b/libfreerdp-core/license.c index fb2edf104..e9df120f0 100644 --- a/libfreerdp-core/license.c +++ b/libfreerdp-core/license.c @@ -207,8 +207,6 @@ void license_generate_randoms(rdpLicense* license) void license_generate_keys(rdpLicense* license) { - int paddingLength; - security_master_secret(license->premaster_secret, license->client_random, license->server_random, license->master_secret); /* MasterSecret */ @@ -540,9 +538,6 @@ void license_read_license_request_packet(rdpLicense* license, STREAM* s) void license_read_platform_challenge_packet(rdpLicense* license, STREAM* s) { - CryptoRc4 rc4; - uint8* platform_challenge; - DEBUG_LICENSE("Receiving Platform Challenge Packet"); stream_seek(s, 4); /* ConnectFlags, Reserved (4 bytes) */ @@ -675,10 +670,10 @@ void license_send_new_license_request_packet(rdpLicense* license) s = license_send_stream_init(license); DEBUG_LICENSE("Sending New License Request Packet"); - license->client_user_name->data = license->rdp->settings->username; - license->client_user_name->length = strlen(license->rdp->settings->username); + license->client_user_name->data = (uint8*)license->rdp->settings->username; + license->client_user_name->length = strlen((char*)license->rdp->settings->username); - license->client_machine_name->data = license->rdp->settings->client_hostname; + license->client_machine_name->data = (uint8*)license->rdp->settings->client_hostname; license->client_machine_name->length = strlen(license->rdp->settings->client_hostname); license_write_new_license_request_packet(license, s); diff --git a/libfreerdp-core/mcs.c b/libfreerdp-core/mcs.c index 14bba3438..8c0df1f4b 100644 --- a/libfreerdp-core/mcs.c +++ b/libfreerdp-core/mcs.c @@ -20,6 +20,8 @@ #include "gcc.h" #include "mcs.h" +#include "tpdu.h" +#include "tpkt.h" /** * T.125 MCS is defined in: diff --git a/libfreerdp-core/mcs.h b/libfreerdp-core/mcs.h index 71b0906a1..306f67383 100644 --- a/libfreerdp-core/mcs.h +++ b/libfreerdp-core/mcs.h @@ -137,6 +137,8 @@ void mcs_send_attach_user_request(rdpMcs* mcs); void mcs_recv_attach_user_confirm(rdpMcs* mcs); void mcs_send_channel_join_request(rdpMcs* mcs, uint16 channel_id); void mcs_recv_channel_join_confirm(rdpMcs* mcs); +boolean mcs_read_domain_mcspdu_header(STREAM* s, enum DomainMCSPDU* domainMCSPDU, int* length); +void mcs_write_domain_mcspdu_header(STREAM* s, enum DomainMCSPDU domainMCSPDU, int length); rdpMcs* mcs_new(rdpTransport* transport); void mcs_free(rdpMcs* mcs); diff --git a/libfreerdp-core/nego.c b/libfreerdp-core/nego.c index a16b354a2..f94748c72 100644 --- a/libfreerdp-core/nego.c +++ b/libfreerdp-core/nego.c @@ -134,7 +134,6 @@ int nego_tcp_disconnect(rdpNego* nego) void nego_attempt_nla(rdpNego* nego) { - uint8 code; nego->requested_protocols = PROTOCOL_NLA | PROTOCOL_TLS; DEBUG_NEGO("Attempting NLA security"); @@ -164,7 +163,6 @@ void nego_attempt_nla(rdpNego* nego) void nego_attempt_tls(rdpNego* nego) { - uint8 code; nego->requested_protocols = PROTOCOL_TLS; DEBUG_NEGO("Attempting TLS security"); @@ -192,7 +190,6 @@ void nego_attempt_tls(rdpNego* nego) void nego_attempt_rdp(rdpNego* nego) { - uint8 code; nego->requested_protocols = PROTOCOL_RDP; DEBUG_NEGO("Attempting RDP security"); @@ -296,7 +293,7 @@ void nego_send_negotiation_request(rdpNego* nego) { int cookie_length = strlen(nego->cookie); stream_write(s, "Cookie: mstshash=", 17); - stream_write(s, nego->cookie, cookie_length); + stream_write(s, (uint8*)nego->cookie, cookie_length); stream_write_uint8(s, 0x0D); /* CR */ stream_write_uint8(s, 0x0A); /* LF */ length += cookie_length + 19; diff --git a/libfreerdp-core/per.c b/libfreerdp-core/per.c index 9289d29b7..6e78595ae 100644 --- a/libfreerdp-core/per.c +++ b/libfreerdp-core/per.c @@ -178,8 +178,6 @@ boolean per_read_integer(STREAM* s, uint32* integer) void per_write_integer(STREAM* s, uint32 integer) { - int length; - if (integer <= 0xFF) { per_write_length(s, 1); @@ -260,7 +258,7 @@ boolean per_read_object_identifier(STREAM* s, uint8 oid[6]) uint8 t12; int length; uint8 a_oid[6]; - boolean status; + per_read_length(s, &length); /* length */ diff --git a/libfreerdp-core/per.h b/libfreerdp-core/per.h index 21d2f6ecb..a00f8b796 100644 --- a/libfreerdp-core/per.h +++ b/libfreerdp-core/per.h @@ -41,5 +41,7 @@ boolean per_read_object_identifier(STREAM* s, uint8 oid[6]); boolean per_read_octet_string(STREAM* s, uint8* oct_str, int length, int min); void per_write_octet_string(STREAM* s, uint8* oct_str, int length, int min); void per_write_numeric_string(STREAM* s, uint8* num_str, int length, int min); +boolean per_read_integer16(STREAM* s, uint16* integer, uint16 min); +void per_write_integer16(STREAM* s, uint16 integer, uint16 min); #endif /* __PER_H */ diff --git a/libfreerdp-core/rdp.c b/libfreerdp-core/rdp.c index 7284c2f10..403dc769c 100644 --- a/libfreerdp-core/rdp.c +++ b/libfreerdp-core/rdp.c @@ -19,6 +19,10 @@ #include "rdp.h" +#include "info.h" +#include "per.h" +#include "redirection.h" + uint8 DATA_PDU_TYPE_STRINGS[][32] = { "", "", /* 0x00 - 0x01 */ diff --git a/libfreerdp-core/registry.c b/libfreerdp-core/registry.c index dde1f92e5..62104dcc0 100644 --- a/libfreerdp-core/registry.c +++ b/libfreerdp-core/registry.c @@ -19,24 +19,24 @@ #include "registry.h" -static uint8 registry_dir[] = "freerdp"; -static uint8 registry_file[] = "config.txt"; +static char registry_dir[] = "freerdp"; +static char registry_file[] = "config.txt"; static REG_SECTION global[] = { - REG_TYPE_SECTION, "global", 0, NULL, - REG_TYPE_BOOLEAN, "fast_path", 1, "1", - REG_TYPE_STRING, "resolution", 8, "1024x768", - REG_TYPE_INTEGER, "performance_flags", 4, "0xFFFF", - REG_TYPE_NONE, "", 0, NULL + { REG_TYPE_SECTION, "global", 0, NULL }, + { REG_TYPE_BOOLEAN, "fast_path", 1, "1" }, + { REG_TYPE_STRING, "resolution", 8, "1024x768" }, + { REG_TYPE_INTEGER, "performance_flags", 4, "0xFFFF" }, + { REG_TYPE_NONE, "", 0, NULL } }; static REG_SECTION licensing[] = { - REG_TYPE_SECTION, "licensing", 0, NULL, - REG_TYPE_STRING, "platform_id", 1, "0x000201", - REG_TYPE_STRING, "hardware_id", 16, "0xe107d9d372bb6826bd81d3542a419d6", - REG_TYPE_NONE, "", 0, NULL + { REG_TYPE_SECTION, "licensing", 0, NULL }, + { REG_TYPE_STRING, "platform_id", 1, "0x000201" }, + { REG_TYPE_STRING, "hardware_id", 16, "0xe107d9d372bb6826bd81d3542a419d6" }, + { REG_TYPE_NONE, "", 0, NULL } }; static REG_SECTION* sections[] = @@ -85,7 +85,8 @@ void registry_print(rdpRegistry* registry, FILE* fp) void registry_create(rdpRegistry* registry) { - registry->fp = fopen(registry->file, "w+"); + registry->fp = fopen((char*)registry->file, "w+"); + if (registry->fp == NULL) { printf("registry_create: error opening [%s] for writing\n", registry->file); @@ -97,14 +98,14 @@ void registry_create(rdpRegistry* registry) void registry_load(rdpRegistry* registry) { - registry->fp = fopen(registry->file, "r+"); + registry->fp = fopen((char*)registry->file, "r+"); } void registry_open(rdpRegistry* registry) { struct stat stat_info; - if (stat(registry->file, &stat_info) != 0) + if (stat((char*)registry->file, &stat_info) != 0) registry_create(registry); else registry_load(registry); @@ -132,10 +133,10 @@ void registry_init(rdpRegistry* registry) return; } - registry->home = (uint8*) xstrdup(home_path); + registry->home = (char*) xstrdup(home_path); printf("home path: %s\n", registry->home); - registry->path = (uint8*) xmalloc(strlen(registry->home) + strlen("/.") + strlen(registry_dir) + 1); + registry->path = (char*) xmalloc(strlen(registry->home) + strlen("/.") + strlen(registry_dir) + 1); sprintf(registry->path, "%s/.%s", registry->home, registry_dir); printf("registry path: %s\n", registry->path); @@ -146,7 +147,7 @@ void registry_init(rdpRegistry* registry) } length = strlen(registry->path); - registry->file = (uint8*) xmalloc(strlen(registry->path) + strlen("/") + strlen(registry_file) + 1); + registry->file = (char*) xmalloc(strlen(registry->path) + strlen("/") + strlen(registry_file) + 1); sprintf(registry->file, "%s/%s", registry->path, registry_file); printf("registry file: %s\n", registry->file); diff --git a/libfreerdp-core/registry.h b/libfreerdp-core/registry.h index 392cc6738..64c3df6b1 100644 --- a/libfreerdp-core/registry.h +++ b/libfreerdp-core/registry.h @@ -41,7 +41,7 @@ enum REG_TYPE typedef struct { uint8 type; - uint8* name; + char* name; uint32 length; void* value; } REG_ENTRY; @@ -54,9 +54,9 @@ typedef REG_ENTRY REG_SECTION; struct rdp_registry { FILE* fp; - uint8* path; - uint8* file; - uint8* home; + char* path; + char* file; + char* home; boolean available; struct rdp_settings* settings; }; diff --git a/libfreerdp-core/security.c b/libfreerdp-core/security.c index 4516417ff..81c494630 100644 --- a/libfreerdp-core/security.c +++ b/libfreerdp-core/security.c @@ -40,7 +40,7 @@ static uint8 pad2[48] = "\x5C\x5C\x5C\x5C\x5C\x5C\x5C\x5C" }; -void security_salted_hash(uint8* salt, uint8* input, int length, uint8* salt1, uint8* salt2, uint8* output) +static void security_salted_hash(uint8* salt, uint8* input, int length, uint8* salt1, uint8* salt2, uint8* output) { CryptoMd5 md5; CryptoSha1 sha1; @@ -63,10 +63,10 @@ void security_salted_hash(uint8* salt, uint8* input, int length, uint8* salt1, u crypto_md5_final(md5, output); } -void security_premaster_hash(uint8* input, int length, uint8* premaster_secret, uint8* client_random, uint8* server_random, uint8* output) +static void security_premaster_hash(char* input, int length, uint8* premaster_secret, uint8* client_random, uint8* server_random, uint8* output) { /* PremasterHash(Input) = SaltedHash(PremasterSecret, Input, ClientRandom, ServerRandom) */ - security_salted_hash(premaster_secret, input, length, client_random, server_random, output); + security_salted_hash(premaster_secret, (uint8*)input, length, client_random, server_random, output); } void security_master_secret(uint8* premaster_secret, uint8* client_random, uint8* server_random, uint8* output) @@ -77,10 +77,10 @@ void security_master_secret(uint8* premaster_secret, uint8* client_random, uint8 security_premaster_hash("CCC", 3, premaster_secret, client_random, server_random, &output[32]); } -void security_master_hash(uint8* input, int length, uint8* master_secret, uint8* client_random, uint8* server_random, uint8* output) +static void security_master_hash(char* input, int length, uint8* master_secret, uint8* client_random, uint8* server_random, uint8* output) { /* MasterHash(Input) = SaltedHash(MasterSecret, Input, ServerRandom, ClientRandom) */ - security_salted_hash(master_secret, input, length, server_random, client_random, output); + security_salted_hash(master_secret, (uint8*)input, length, server_random, client_random, output); } void security_session_key_blob(uint8* master_secret, uint8* client_random, uint8* server_random, uint8* output) diff --git a/libfreerdp-core/security.h b/libfreerdp-core/security.h index db8a0f99f..82add4eb1 100644 --- a/libfreerdp-core/security.h +++ b/libfreerdp-core/security.h @@ -26,10 +26,7 @@ #include #include -void security_salted_hash(uint8* salt, uint8* input, int length, uint8* salt1, uint8* salt2, uint8* output); -void security_premaster_hash(uint8* input, int length, uint8* premaster_secret, uint8* client_random, uint8* server_random, uint8* output); void security_master_secret(uint8* premaster_secret, uint8* client_random, uint8* server_random, uint8* output); -void security_master_hash(uint8* input, int length, uint8* master_secret, uint8* client_random, uint8* server_random, uint8* output); void security_session_key_blob(uint8* master_secret, uint8* client_random, uint8* server_random, uint8* output); void security_mac_salt_key(uint8* session_key_blob, uint8* client_random, uint8* server_random, uint8* output); void security_licensing_encryption_key(uint8* session_key_blob, uint8* client_random, uint8* server_random, uint8* output); diff --git a/libfreerdp-core/settings.c b/libfreerdp-core/settings.c index 9e0d30e34..2da6b3da7 100644 --- a/libfreerdp-core/settings.c +++ b/libfreerdp-core/settings.c @@ -101,7 +101,7 @@ rdpSettings* settings_new() settings->draw_nine_grid_cache_size = 2560; settings->draw_nine_grid_cache_entries = 256; - settings->client_dir = (uint8*)xstrdup(client_dll); + settings->client_dir = xstrdup(client_dll); settings->uniconv = freerdp_uniconv_new(); gethostname(settings->client_hostname, sizeof(settings->client_hostname) - 1); diff --git a/libfreerdp-core/tcp.c b/libfreerdp-core/tcp.c index c758bfd7e..7ac99ec54 100644 --- a/libfreerdp-core/tcp.c +++ b/libfreerdp-core/tcp.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -46,11 +47,12 @@ void tcp_get_ip_address(rdpTcp * tcp) { ip = (uint8*) (&sockaddr.sin_addr); snprintf(tcp->ip_address, sizeof(tcp->ip_address), - "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]); + "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]); } - else + { strncpy(tcp->ip_address, "127.0.0.1", sizeof(tcp->ip_address)); + } tcp->ip_address[sizeof(tcp->ip_address) - 1] = 0; @@ -91,7 +93,7 @@ void tcp_get_mac_address(rdpTcp * tcp) mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); */ } -boolean tcp_connect(rdpTcp* tcp, const uint8* hostname, uint16 port) +boolean tcp_connect(rdpTcp* tcp, const char* hostname, uint16 port) { int status; int sockfd = -1; diff --git a/libfreerdp-core/tcp.h b/libfreerdp-core/tcp.h index bb0538bd1..046bb73e5 100644 --- a/libfreerdp-core/tcp.h +++ b/libfreerdp-core/tcp.h @@ -31,14 +31,14 @@ typedef struct rdp_tcp rdpTcp; -typedef boolean (*TcpConnect) (rdpTcp* tcp, const uint8* hostname, uint16 port); +typedef boolean (*TcpConnect) (rdpTcp* tcp, const char* hostname, uint16 port); typedef boolean (*TcpDisconnect) (rdpTcp* tcp); typedef boolean (*TcpSetBlockingMode) (rdpTcp* tcp, boolean blocking); struct rdp_tcp { int sockfd; - uint8 ip_address[32]; + char ip_address[32]; uint8 mac_address[6]; struct rdp_settings* settings; TcpConnect connect; @@ -46,7 +46,7 @@ struct rdp_tcp TcpSetBlockingMode set_blocking_mode; }; -boolean tcp_connect(rdpTcp* tcp, const uint8* hostname, uint16 port); +boolean tcp_connect(rdpTcp* tcp, const char* hostname, uint16 port); boolean tcp_disconnect(rdpTcp* tcp); int tcp_read(rdpTcp* tcp, uint8* data, int length); int tcp_write(rdpTcp* tcp, uint8* data, int length); diff --git a/libfreerdp-core/transport.c b/libfreerdp-core/transport.c index 564533db4..aacd96221 100644 --- a/libfreerdp-core/transport.c +++ b/libfreerdp-core/transport.c @@ -51,7 +51,7 @@ STREAM* transport_send_stream_init(rdpTransport* transport, int size) return s; } -boolean transport_connect(rdpTransport* transport, const uint8* hostname, uint16 port) +boolean transport_connect(rdpTransport* transport, const char* hostname, uint16 port) { return transport->tcp->connect(transport->tcp, hostname, port); } diff --git a/libfreerdp-core/transport.h b/libfreerdp-core/transport.h index 449b64684..23c97cb7b 100644 --- a/libfreerdp-core/transport.h +++ b/libfreerdp-core/transport.h @@ -67,7 +67,7 @@ struct rdp_transport STREAM* transport_recv_stream_init(rdpTransport* transport, int size); STREAM* transport_send_stream_init(rdpTransport* transport, int size); -boolean transport_connect(rdpTransport* transport, const uint8* hostname, uint16 port); +boolean transport_connect(rdpTransport* transport, const char* hostname, uint16 port); boolean transport_disconnect(rdpTransport* transport); boolean transport_connect_rdp(rdpTransport* transport); boolean transport_connect_tls(rdpTransport* transport); diff --git a/libfreerdp-core/update.c b/libfreerdp-core/update.c index 440978fc7..22bfa79f5 100644 --- a/libfreerdp-core/update.c +++ b/libfreerdp-core/update.c @@ -18,6 +18,7 @@ */ #include "update.h" +#include "bitmap.h" uint8 UPDATE_TYPE_STRINGS[][32] = { diff --git a/libfreerdp-utils/args.c b/libfreerdp-utils/args.c index a18489692..f3b62a6e1 100644 --- a/libfreerdp-utils/args.c +++ b/libfreerdp-utils/args.c @@ -69,7 +69,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, printf("missing username\n"); return 0; } - settings->username = (uint8*)xstrdup(argv[index]); + settings->username = xstrdup(argv[index]); } else if (strcmp("-p", argv[index]) == 0) { @@ -79,7 +79,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, printf("missing password\n"); return 0; } - settings->password = (uint8*)xstrdup(argv[index]); + settings->password = xstrdup(argv[index]); settings->autologon = 1; /* @@ -97,7 +97,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, printf("missing domain\n"); return 0; } - settings->domain = (uint8*)xstrdup(argv[index]); + settings->domain = xstrdup(argv[index]); } else if (strcmp("-s", argv[index]) == 0) { @@ -107,7 +107,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, printf("missing shell\n"); return 0; } - settings->shell = (uint8*)xstrdup(argv[index]); + settings->shell = xstrdup(argv[index]); } else if (strcmp("-c", argv[index]) == 0) { @@ -117,7 +117,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, printf("missing directory\n"); return 0; } - settings->directory = (uint8*)xstrdup(argv[index]); + settings->directory = xstrdup(argv[index]); } else if (strcmp("-g", argv[index]) == 0) { @@ -349,7 +349,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, && (p[1] == 0 || (p[1] == ':' && !strchr(p + 2, ':')))) { /* Either "[...]" or "[...]:..." with at most one : after the brackets */ - settings->hostname = (uint8*)xstrdup(argv[index] + 1); + settings->hostname = xstrdup(argv[index] + 1); if ((p = strchr((char*)settings->hostname, ']'))) { *p = 0; @@ -360,7 +360,7 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv, else { /* Port number is cut off and used if exactly one : in the string */ - settings->hostname = (uint8*)xstrdup(argv[index]); + settings->hostname = xstrdup(argv[index]); if ((p = strchr((char*)settings->hostname, ':')) && !strchr(p + 1, ':')) { *p = 0; From 7e79e43ddc14141a103ab28a6f263a5b308e9e76 Mon Sep 17 00:00:00 2001 From: Brad Hards Date: Wed, 27 Jul 2011 16:37:52 +1000 Subject: [PATCH 2/5] libfreerdp-core: use uint16 for the PER length. --- libfreerdp-core/gcc.c | 2 +- libfreerdp-core/per.c | 8 ++++---- libfreerdp-core/per.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libfreerdp-core/gcc.c b/libfreerdp-core/gcc.c index b97ff2c37..abd655914 100644 --- a/libfreerdp-core/gcc.c +++ b/libfreerdp-core/gcc.c @@ -160,7 +160,7 @@ void gcc_write_conference_create_request(STREAM* s, STREAM* user_data) void gcc_read_conference_create_response(STREAM* s, rdpSettings* settings) { - int length; + uint16 length; uint32 tag; uint16 nodeID; uint8 result; diff --git a/libfreerdp-core/per.c b/libfreerdp-core/per.c index 6e78595ae..77125fca5 100644 --- a/libfreerdp-core/per.c +++ b/libfreerdp-core/per.c @@ -26,7 +26,7 @@ * @return */ -boolean per_read_length(STREAM* s, int* length) +boolean per_read_length(STREAM* s, uint16* length) { uint8 byte; @@ -156,7 +156,7 @@ void per_write_padding(STREAM* s, int length) boolean per_read_integer(STREAM* s, uint32* integer) { - int length; + uint16 length; per_read_length(s, &length); @@ -256,7 +256,7 @@ boolean per_read_enumerated(STREAM* s, uint8* enumerated, uint8 count) boolean per_read_object_identifier(STREAM* s, uint8 oid[6]) { uint8 t12; - int length; + uint16 length; uint8 a_oid[6]; @@ -330,7 +330,7 @@ void per_write_string(STREAM* s, uint8* str, int length) boolean per_read_octet_string(STREAM* s, uint8* oct_str, int length, int min) { int i; - int mlength; + uint16 mlength; uint8* a_oct_str; per_read_length(s, &mlength); diff --git a/libfreerdp-core/per.h b/libfreerdp-core/per.h index a00f8b796..0c5dc039c 100644 --- a/libfreerdp-core/per.h +++ b/libfreerdp-core/per.h @@ -22,7 +22,7 @@ #include -boolean per_read_length(STREAM* s, int* length); +boolean per_read_length(STREAM* s, uint16* length); void per_write_length(STREAM* s, int length); boolean per_read_choice(STREAM* s, uint8* choice); void per_write_choice(STREAM* s, uint8 choice); From 8761b1d9a85f61d41c99980d22ff50e459fd9f94 Mon Sep 17 00:00:00 2001 From: Brad Hards Date: Wed, 27 Jul 2011 16:41:00 +1000 Subject: [PATCH 3/5] libfreerdp-core: fix warning about | operator. --- libfreerdp-core/ber.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libfreerdp-core/ber.c b/libfreerdp-core/ber.c index ac05fada0..3e4288927 100644 --- a/libfreerdp-core/ber.c +++ b/libfreerdp-core/ber.c @@ -90,7 +90,7 @@ boolean ber_read_universal_tag(STREAM* s, uint8 tag, boolean pc) stream_read_uint8(s, byte); - if (byte != (BER_CLASS_UNIV | BER_PC(pc)) | (BER_TAG_MASK & tag)) + if (byte != (BER_CLASS_UNIV | BER_PC(pc) | (BER_TAG_MASK & tag))) return False; return True; From cb7535bbb5f8b6de7912dd5d69f032a9bd064b66 Mon Sep 17 00:00:00 2001 From: Brad Hards Date: Wed, 27 Jul 2011 19:06:15 +1000 Subject: [PATCH 4/5] client/test: fix string handling --- client/test/freerdp.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/test/freerdp.c b/client/test/freerdp.c index 44cff14d9..2c831c0b5 100644 --- a/client/test/freerdp.c +++ b/client/test/freerdp.c @@ -34,7 +34,7 @@ } while(0) #define STRING_COPY(_str) do { \ - settings->_str = xmalloc(strlen(argv[*i])); \ + settings->_str = xmalloc(strlen(argv[*i]) + 1); \ memcpy(settings->_str, argv[*i], strlen(argv[*i])); \ settings->_str[strlen(argv[*i])] = '\0'; \ } while(0) @@ -145,7 +145,7 @@ boolean freerdp_process_params(int argc, char* argv[], rdpSettings* settings, in && (p[1] == 0 || (p[1] == ':' && !strchr(p + 2, ':')))) { /* Either "[...]" or "[...]:..." with at most one : after the brackets */ - settings->hostname = (char*) xmalloc(strlen(argv[*i] + 1)); + settings->hostname = (char*) xmalloc(strlen(argv[*i]) + 1); strncpy(settings->hostname, argv[*i] + 1, strlen(argv[*i] + 1)); if ((p = strchr((const char*)settings->hostname, ']'))) @@ -158,10 +158,11 @@ boolean freerdp_process_params(int argc, char* argv[], rdpSettings* settings, in else { /* Port number is cut off and used if exactly one : in the string */ - settings->hostname = (char*) xmalloc(strlen(argv[*i])); + settings->hostname = (char*) xmalloc(strlen(argv[*i]) + 1); strncpy(settings->hostname, argv[*i], strlen(argv[*i])); + settings->hostname[strlen(argv[*i])] = '\0'; - if ((p = strchr((const char*)settings->hostname, ':')) && !strchr(p + 1, ':')) + if ((p = strchr(settings->hostname, ':')) && !strchr(p + 1, ':')) { *p = 0; settings->port = (uint16) atoi(p + 1); From 646257ed8e3a0bb428f1d8f0c40b94b01b0e6cbe Mon Sep 17 00:00:00 2001 From: Dorian Johnson <2011@dorianj.net> Date: Wed, 27 Jul 2011 08:45:44 -0500 Subject: [PATCH 5/5] gdi: in gdi_free, use gdi_DeleteDC to release gdi->hdc instead of incorrect gdi_DeleteObject --- libfreerdp-gdi/gdi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libfreerdp-gdi/gdi.c b/libfreerdp-gdi/gdi.c index 369d51396..3a3d2e3f4 100644 --- a/libfreerdp-gdi/gdi.c +++ b/libfreerdp-gdi/gdi.c @@ -1186,7 +1186,7 @@ void gdi_free(rdpInst* inst) if (gdi) { gdi_bitmap_free(gdi->primary); - gdi_DeleteObject((HGDIOBJECT) gdi->hdc); + gdi_DeleteDC(gdi->hdc); free(gdi->clrconv); free(gdi); }