Merge pull request #11538 from akallabeth/fixes

Fixes
This commit is contained in:
akallabeth
2025-04-28 17:37:54 +02:00
committed by GitHub
3 changed files with 17 additions and 20 deletions

View File

@@ -4857,7 +4857,6 @@ static BOOL rdp_write_confirm_active(wLog* log, wStream* s, rdpSettings* setting
return FALSE;
}
if (settings->OffscreenSupportLevel)
{
numberCapabilities++;

View File

@@ -1498,19 +1498,16 @@ BOOL gcc_write_client_core_data(wStream* s, const rdpMcs* mcs)
if (!Stream_EnsureRemainingCapacity(s, 64 + 24))
return FALSE;
/* clientDigProductId (64 bytes, null-terminated unicode, truncated to 31 characters) */
size_t clientDigProductIdLength = 0;
WCHAR* clientDigProductId =
ConvertUtf8ToWCharAlloc(settings->ClientProductId, &clientDigProductIdLength);
if (clientDigProductIdLength >= 32)
/* clientDigProductId (64 bytes, assume WCHAR, not \0 terminated */
const char* str = freerdp_settings_get_string(settings, FreeRDP_ClientProductId);
if (str)
{
clientDigProductIdLength = 32;
clientDigProductId[clientDigProductIdLength - 1] = 0;
if (Stream_Write_UTF16_String_From_UTF8(s, 32, str, strnlen(str, 32), TRUE) < 0)
return FALSE;
}
else
Stream_Zero(s, 32 * sizeof(WCHAR));
Stream_Write(s, clientDigProductId, (clientDigProductIdLength * 2));
Stream_Zero(s, 64 - (clientDigProductIdLength * 2));
free(clientDigProductId);
Stream_Write_UINT8(s, connectionType); /* connectionType */
Stream_Write_UINT8(s, 0); /* pad1octet */
Stream_Write_UINT32(s, settings->SelectedProtocol); /* serverSelectedProtocol */

View File

@@ -466,19 +466,20 @@ BOOL Stream_CheckAndLogRequiredLengthWLogExVa(wLog* log, DWORD level, wStream* s
SSIZE_T Stream_Write_UTF16_String_From_UTF8(wStream* s, size_t wcharLength, const char* src,
size_t length, BOOL fill)
{
SSIZE_T rc = 0;
WCHAR* str = Stream_PointerAs(s, WCHAR);
if (length == 0)
return 0;
if (length != 0)
{
if (!Stream_CheckAndLogRequiredCapacityOfSize(STREAM_TAG, s, wcharLength, sizeof(WCHAR)))
return -1;
if (!Stream_CheckAndLogRequiredCapacityOfSize(STREAM_TAG, s, wcharLength, sizeof(WCHAR)))
return -1;
rc = ConvertUtf8NToWChar(src, length, str, wcharLength);
if (rc < 0)
return -1;
SSIZE_T rc = ConvertUtf8NToWChar(src, length, str, wcharLength);
if (rc < 0)
return -1;
Stream_Seek(s, (size_t)rc * sizeof(WCHAR));
Stream_Seek(s, (size_t)rc * sizeof(WCHAR));
}
if (fill)
Stream_Zero(s, (wcharLength - (size_t)rc) * sizeof(WCHAR));