From 738cbd54b26aa80af105fc435e3652e7552e89bf Mon Sep 17 00:00:00 2001 From: akallabeth Date: Tue, 22 Oct 2024 12:21:43 +0200 Subject: [PATCH] [core] fix issues with value ranges written --- libfreerdp/core/multitransport.c | 6 +++++- libfreerdp/core/timezone.c | 28 +++++++++++++++++++++------- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/libfreerdp/core/multitransport.c b/libfreerdp/core/multitransport.c index ce29d9908..492ec6824 100644 --- a/libfreerdp/core/multitransport.c +++ b/libfreerdp/core/multitransport.c @@ -151,7 +151,11 @@ BOOL multitransport_client_send_response(rdpMultitransport* multi, UINT32 reqId, } Stream_Write_UINT32(s, reqId); /* requestId (4 bytes) */ - Stream_Write_UINT32(s, hr); /* HResult (4 bytes) */ + + /* [MS-RDPBCGR] 2.2.15.2 Client Initiate Multitransport Response PDU defines this as 4byte + * UNSIGNED but https://learn.microsoft.com/en-us/windows/win32/learnwin32/error-codes-in-com + * defines this as signed... assume the spec is (implicitly) assuming twos complement. */ + Stream_Write_INT32(s, hr); /* HResult (4 bytes) */ return rdp_send_message_channel_pdu(multi->rdp, s, SEC_TRANSPORT_RSP); } diff --git a/libfreerdp/core/timezone.c b/libfreerdp/core/timezone.c index cfd225304..5369a50bb 100644 --- a/libfreerdp/core/timezone.c +++ b/libfreerdp/core/timezone.c @@ -226,10 +226,8 @@ BOOL rdp_read_client_time_zone(wStream* s, rdpSettings* settings) BOOL rdp_write_client_time_zone(wStream* s, rdpSettings* settings) { - LPTIME_ZONE_INFORMATION tz = { 0 }; - WINPR_ASSERT(settings); - tz = settings->ClientTimeZone; + const LPTIME_ZONE_INFORMATION tz = settings->ClientTimeZone; if (!tz) return FALSE; @@ -238,8 +236,12 @@ BOOL rdp_write_client_time_zone(wStream* s, rdpSettings* settings) if (!Stream_EnsureRemainingCapacity(s, 4ull + sizeof(tz->StandardName))) return FALSE; - /* Bias */ - Stream_Write_UINT32(s, tz->Bias); + /* Bias defined in windows headers as LONG + * but [MS-RDPBCGR] 2.2.1.11.1.1.1.1 Time Zone Information (TS_TIME_ZONE_INFORMATION) defines it + * as unsigned.... assume the spec is buggy as an unsigned value only works on half of the + * world. + */ + Stream_Write_INT32(s, tz->Bias); /* standardName (64 bytes) */ Stream_Write(s, tz->StandardName, sizeof(tz->StandardName)); /* StandardDate */ @@ -250,7 +252,13 @@ BOOL rdp_write_client_time_zone(wStream* s, rdpSettings* settings) /* StandardBias */ if (!Stream_EnsureRemainingCapacity(s, 4ull + sizeof(tz->DaylightName))) return FALSE; - Stream_Write_UINT32(s, tz->StandardBias); + + /* StandardBias defined in windows headers as LONG + * but [MS-RDPBCGR] 2.2.1.11.1.1.1.1 Time Zone Information (TS_TIME_ZONE_INFORMATION) defines it + * as unsigned.... assume the spec is buggy as an unsigned value only works on half of the + * world. + */ + Stream_Write_INT32(s, tz->StandardBias); /* daylightName (64 bytes) */ Stream_Write(s, tz->DaylightName, sizeof(tz->DaylightName)); @@ -261,7 +269,13 @@ BOOL rdp_write_client_time_zone(wStream* s, rdpSettings* settings) /* DaylightBias */ if (!Stream_EnsureRemainingCapacity(s, 4ull)) return FALSE; - Stream_Write_UINT32(s, tz->DaylightBias); + + /* DaylightBias defined in windows headers as LONG + * but [MS-RDPBCGR] 2.2.1.11.1.1.1.1 Time Zone Information (TS_TIME_ZONE_INFORMATION) defines it + * as unsigned.... assume the spec is buggy as an unsigned value only works on half of the + * world. + */ + Stream_Write_INT32(s, tz->DaylightBias); return TRUE; }