Skip to content

Commit 119c707

Browse files
authored
fix!: update timezone info to use i32 bias (#921)
Switches `bias` from an unsigned to a signed integer. This matches the updated specification from Microsoft.
1 parent a6e0364 commit 119c707

2 files changed

Lines changed: 30 additions & 11 deletions

File tree

crates/ironrdp-pdu/src/rdp/client_info.rs

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -383,15 +383,20 @@ impl<'de> Decode<'de> for ExtendedClientOptionalInfo {
383383
}
384384
}
385385

386+
/// [2.2.1.11.1.1.1.1] Time Zone Information (TS_TIME_ZONE_INFORMATION)
387+
///
388+
/// The timezone info struct contains client time zone information.
389+
///
390+
/// [2.2.1.11.1.1.1.1]: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/526ed635-d7a9-4d3c-bbe1-4e3fb17585f4
386391
#[derive(Debug, Clone, PartialEq, Eq)]
387392
pub struct TimezoneInfo {
388-
pub bias: u32,
393+
pub bias: i32,
389394
pub standard_name: String,
390395
pub standard_date: OptionalSystemTime,
391-
pub standard_bias: u32,
396+
pub standard_bias: i32,
392397
pub daylight_name: String,
393398
pub daylight_date: OptionalSystemTime,
394-
pub daylight_bias: u32,
399+
pub daylight_bias: i32,
395400
}
396401

397402
impl TimezoneInfo {
@@ -410,21 +415,21 @@ impl Encode for TimezoneInfo {
410415
fn encode(&self, dst: &mut WriteCursor<'_>) -> EncodeResult<()> {
411416
ensure_fixed_part_size!(in: dst);
412417

413-
dst.write_u32(self.bias);
418+
dst.write_i32(self.bias);
414419

415420
let mut standard_name = utils::to_utf16_bytes(self.standard_name.as_str());
416421
standard_name.resize(TIMEZONE_INFO_NAME_LEN, 0);
417422
dst.write_slice(&standard_name);
418423

419424
self.standard_date.encode(dst)?;
420-
dst.write_u32(self.standard_bias);
425+
dst.write_i32(self.standard_bias);
421426

422427
let mut daylight_name = utils::to_utf16_bytes(self.daylight_name.as_str());
423428
daylight_name.resize(TIMEZONE_INFO_NAME_LEN, 0);
424429
dst.write_slice(&daylight_name);
425430

426431
self.daylight_date.encode(dst)?;
427-
dst.write_u32(self.daylight_bias);
432+
dst.write_i32(self.daylight_bias);
428433

429434
Ok(())
430435
}
@@ -442,14 +447,14 @@ impl<'de> Decode<'de> for TimezoneInfo {
442447
fn decode(src: &mut ReadCursor<'de>) -> DecodeResult<Self> {
443448
ensure_fixed_part_size!(in: src);
444449

445-
let bias = src.read_u32();
450+
let bias = src.read_i32();
446451
let standard_name = utils::decode_string(src.read_slice(TIMEZONE_INFO_NAME_LEN), CharacterSet::Unicode, false)?;
447452
let standard_date = OptionalSystemTime::decode(src)?;
448-
let standard_bias = src.read_u32();
453+
let standard_bias = src.read_i32();
449454

450455
let daylight_name = utils::decode_string(src.read_slice(TIMEZONE_INFO_NAME_LEN), CharacterSet::Unicode, false)?;
451456
let daylight_date = OptionalSystemTime::decode(src)?;
452-
let daylight_bias = src.read_u32();
457+
let daylight_bias = src.read_i32();
453458

454459
Ok(Self {
455460
bias,
@@ -463,6 +468,20 @@ impl<'de> Decode<'de> for TimezoneInfo {
463468
}
464469
}
465470

471+
impl Default for TimezoneInfo {
472+
fn default() -> Self {
473+
Self {
474+
bias: 0,
475+
standard_name: String::new(),
476+
standard_date: OptionalSystemTime(None),
477+
standard_bias: 0,
478+
daylight_name: String::new(),
479+
daylight_date: OptionalSystemTime(None),
480+
daylight_bias: 0,
481+
}
482+
}
483+
}
484+
466485
#[derive(Debug, Clone, PartialEq, Eq)]
467486
pub struct SystemTime {
468487
pub month: Month,

crates/ironrdp-testsuite-core/src/client_info.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ lazy_static::lazy_static! {
105105
dir: String::from("C:\\depots\\w2k3_1\\termsrv\\newclient\\lib\\win32\\obj\\i386\\mstscax.dll"),
106106
optional_data: ExtendedClientOptionalInfo::builder()
107107
.timezone(TimezoneInfo {
108-
bias: 0x01e0,
108+
bias: 480,
109109
standard_name: String::from("Pacific Standard Time"),
110110
standard_date: OptionalSystemTime(Some(SystemTime {
111111
month: Month::October,
@@ -127,7 +127,7 @@ lazy_static::lazy_static! {
127127
second: 0,
128128
milliseconds: 0,
129129
})),
130-
daylight_bias: 0xffff_ffc4,
130+
daylight_bias: -60,
131131
})
132132
.session_id(0)
133133
.performance_flags(PerformanceFlags::DISABLE_WALLPAPER)

0 commit comments

Comments
 (0)