Merge pull request #862 from Osirium/pull/unicode-len

ConvertToUnicode returns the number of wide characters including the NUL...
This commit is contained in:
Marc-André Moreau 2012-12-18 06:55:29 -08:00
commit 3f3b8f7140

View File

@ -681,14 +681,14 @@ void gcc_write_client_core_data(STREAM* s, rdpSettings* settings)
/* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */ /* clientName (32 bytes, null-terminated unicode, truncated to 15 characters) */
if (clientNameLength > 15) if (clientNameLength >= 16)
{ {
clientNameLength = 15; clientNameLength = 16;
clientName[clientNameLength] = 0; clientName[clientNameLength-1] = 0;
} }
stream_write(s, clientName, ((clientNameLength + 1) * 2)); stream_write(s, clientName, (clientNameLength * 2));
stream_write_zero(s, 32 - ((clientNameLength + 1) * 2)); stream_write_zero(s, 32 - (clientNameLength * 2));
free(clientName); free(clientName);
stream_write_UINT32(s, settings->KeyboardType); /* KeyboardType */ 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 */ stream_write_UINT16(s, earlyCapabilityFlags); /* earlyCapabilityFlags */
/* clientDigProductId (64 bytes, null-terminated unicode, truncated to 30 characters) */ /* clientDigProductId (64 bytes, null-terminated unicode, truncated to 31 characters) */
if (clientDigProductIdLength > 62) if (clientDigProductIdLength >= 32)
{ {
clientDigProductIdLength = 62; clientDigProductIdLength = 32;
clientDigProductId[clientDigProductIdLength] = 0; clientDigProductId[clientDigProductIdLength-1] = 0;
clientDigProductId[clientDigProductIdLength + 1] = 0;
} }
stream_write(s, clientDigProductId, clientDigProductIdLength + 2); stream_write(s, clientDigProductId, (clientDigProductIdLength * 2) );
stream_write_zero(s, 64 - clientDigProductIdLength - 2); stream_write_zero(s, 64 - (clientDigProductIdLength * 2) );
free(clientDigProductId); free(clientDigProductId);
stream_write_BYTE(s, connectionType); /* connectionType */ stream_write_BYTE(s, connectionType); /* connectionType */