mirror of
https://github.com/netbirdio/IronRDP.git
synced 2026-05-22 18:43:12 -07:00
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 <marcandre.lureau@redhat.com>
This commit is contained in:
@@ -39,7 +39,10 @@ impl FastPathHeader {
|
||||
}
|
||||
|
||||
fn minimal_size(&self) -> usize {
|
||||
Self::FIXED_PART_SIZE + per::sizeof_length(self.data_length as u16)
|
||||
// it may then be +2 if > 0x7f
|
||||
let len = self.data_length + Self::FIXED_PART_SIZE + 1;
|
||||
|
||||
Self::FIXED_PART_SIZE + per::sizeof_length(len as u16)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -140,3 +140,19 @@ fn to_buffer_correctly_serializes_fast_path_update() {
|
||||
fn buffer_length_is_correct_for_fast_path_update() {
|
||||
assert_eq!(FAST_PATH_UPDATE_PDU_BUFFER.len(), FAST_PATH_UPDATE_PDU.size());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn buffer_size_boundary_fast_path_update() {
|
||||
let fph = FastPathHeader {
|
||||
flags: EncryptionFlags::ENCRYPTED,
|
||||
data_length: 125,
|
||||
forced_long_length: false,
|
||||
};
|
||||
assert_eq!(fph.size(), 2);
|
||||
let fph = FastPathHeader {
|
||||
flags: EncryptionFlags::ENCRYPTED,
|
||||
data_length: 126,
|
||||
forced_long_length: false,
|
||||
};
|
||||
assert_eq!(fph.size(), 3);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user