mirror of
https://github.com/rustdesk/rustdesk.git
synced 2026-10-20 00:17:55 +00:00
Fix, online state, validate the data length (#16339)
* fix(client): reject truncated online status responses Validate the bitmap length before indexing server-provided states. Return an error for short responses so they cannot panic or update cached online status. Signed-off-by: fufesou <linlong1266@gmail.com> * docs(client): illustrate online status bitmap sizing Signed-off-by: fufesou <linlong1266@gmail.com> --------- Signed-off-by: fufesou <linlong1266@gmail.com>
This commit is contained in:
@@ -5369,6 +5369,15 @@ pub mod peer_online {
|
||||
match msg_in.union {
|
||||
Some(rendezvous_message::Union::OnlineResponse(online_response)) => {
|
||||
let states = online_response.states;
|
||||
// One bit per ID, rounded up to whole bytes:
|
||||
// 0 IDs -> 0 bytes; 1..=8 -> 1; 9..=16 -> 2; 17..=24 -> 3.
|
||||
let required_len = ids.len().div_ceil(u8::BITS as usize);
|
||||
if states.len() < required_len {
|
||||
bail!(
|
||||
"Invalid online response: expected at least {required_len} state bytes, got {}",
|
||||
states.len()
|
||||
);
|
||||
}
|
||||
let mut onlines = Vec::new();
|
||||
let mut offlines = Vec::new();
|
||||
for i in 0..ids.len() {
|
||||
|
||||
Reference in New Issue
Block a user