Skip to content

Commit 3b9d558

Browse files
authored
fix(pdu): fix FastPathHeader minimal size (#687)
The minimal_size() logic didn't properly take into account the overall PDU size. This fixes random error/disconnect in client. Signed-off-by: Marc-André Lureau <[email protected]>
1 parent 6e8a823 commit 3b9d558

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

crates/ironrdp-pdu/src/basic_output/fast_path.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ impl FastPathHeader {
3939
}
4040

4141
fn minimal_size(&self) -> usize {
42-
Self::FIXED_PART_SIZE + per::sizeof_length(self.data_length as u16)
42+
// it may then be +2 if > 0x7f
43+
let len = self.data_length + Self::FIXED_PART_SIZE + 1;
44+
45+
Self::FIXED_PART_SIZE + per::sizeof_length(len as u16)
4346
}
4447
}
4548

crates/ironrdp-pdu/src/basic_output/fast_path/tests.rs

+16
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,19 @@ fn to_buffer_correctly_serializes_fast_path_update() {
140140
fn buffer_length_is_correct_for_fast_path_update() {
141141
assert_eq!(FAST_PATH_UPDATE_PDU_BUFFER.len(), FAST_PATH_UPDATE_PDU.size());
142142
}
143+
144+
#[test]
145+
fn buffer_size_boundary_fast_path_update() {
146+
let fph = FastPathHeader {
147+
flags: EncryptionFlags::ENCRYPTED,
148+
data_length: 125,
149+
forced_long_length: false,
150+
};
151+
assert_eq!(fph.size(), 2);
152+
let fph = FastPathHeader {
153+
flags: EncryptionFlags::ENCRYPTED,
154+
data_length: 126,
155+
forced_long_length: false,
156+
};
157+
assert_eq!(fph.size(), 3);
158+
}

0 commit comments

Comments
 (0)