From a6178d929747fd4250bc1c8c641dfb917051b408 Mon Sep 17 00:00:00 2001 From: LawrenceK Date: Tue, 18 Dec 2012 13:55:43 +0000 Subject: [PATCH] ConvertToUnicode returns the number of wide characters including the NULL terminator. --- libfreerdp/core/gcc.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/libfreerdp/core/gcc.c b/libfreerdp/core/gcc.c index 68b650e3f..417284542 100644 --- a/libfreerdp/core/gcc.c +++ b/libfreerdp/core/gcc.c @@ -681,14 +681,14 @@ void gcc_write_client_core_data(STREAM* s, rdpSettings* settings) /* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */ - if (clientNameLength > 15) + if (clientNameLength >= 16) { - clientNameLength = 15; - clientName[clientNameLength] = 0; + clientNameLength = 16; + clientName[clientNameLength-1] = 0; } - stream_write(s, clientName, ((clientNameLength + 1) * 2)); - stream_write_zero(s, 32 - ((clientNameLength + 1) * 2)); + stream_write(s, clientName, (clientNameLength * 2)); + stream_write_zero(s, 32 - (clientNameLength * 2)); free(clientName); stream_write_UINT32(s, settings->KeyboardType); /* KeyboardType */ @@ -728,15 +728,14 @@ void gcc_write_client_core_data(STREAM* s, rdpSettings* settings) stream_write_UINT16(s, earlyCapabilityFlags); /* earlyCapabilityFlags */ - /* clientDigProductId (64 bytes, null-terminated unicode, truncated to 30 characters) */ - if (clientDigProductIdLength > 62) + /* clientDigProductId (64 bytes, null-terminated unicode, truncated to 31 characters) */ + if (clientDigProductIdLength >= 32) { - clientDigProductIdLength = 62; - clientDigProductId[clientDigProductIdLength] = 0; - clientDigProductId[clientDigProductIdLength + 1] = 0; + clientDigProductIdLength = 32; + clientDigProductId[clientDigProductIdLength-1] = 0; } - stream_write(s, clientDigProductId, clientDigProductIdLength + 2); - stream_write_zero(s, 64 - clientDigProductIdLength - 2); + stream_write(s, clientDigProductId, (clientDigProductIdLength * 2) ); + stream_write_zero(s, 64 - (clientDigProductIdLength * 2) ); free(clientDigProductId); stream_write_BYTE(s, connectionType); /* connectionType */