fix(hive-screen-mcp): address argus review 🟡 items
- mouse_click: error on unrecognised button name instead of silently treating it as left click; "left" now explicit in match arm - rfb_handshake: cap ServerInit name-length at 256 bytes to prevent a multi-GB allocation from an aberrant server response
This commit is contained in:
parent
74fdbe7c43
commit
cb4421228e
1 changed files with 11 additions and 1 deletions
|
|
@ -147,6 +147,11 @@ async fn rfb_handshake(stream: &mut TcpStream) -> Result<(), String> {
|
|||
.read_u32()
|
||||
.await
|
||||
.map_err(|e| format!("VNC: read name-len: {e}"))?;
|
||||
if name_len > 256 {
|
||||
return Err(format!(
|
||||
"VNC: server-init name length {name_len} exceeds cap (256)"
|
||||
));
|
||||
}
|
||||
let mut name = vec![0u8; name_len as usize];
|
||||
stream
|
||||
.read_exact(&mut name)
|
||||
|
|
@ -283,9 +288,14 @@ impl ScreenMcp {
|
|||
return "mouse_click: x and y must be in range 0–65535".to_owned();
|
||||
};
|
||||
let btn_mask: u8 = match args.button.as_deref().unwrap_or("left") {
|
||||
"left" => 0b0000_0001,
|
||||
"right" => 0b0000_0100,
|
||||
"middle" => 0b0000_0010,
|
||||
_ => 0b0000_0001, // left
|
||||
other => {
|
||||
return format!(
|
||||
"mouse_click: unknown button {other:?} — use \"left\", \"right\", or \"middle\""
|
||||
)
|
||||
}
|
||||
};
|
||||
// Move to position, press, release — all in one VNC connection.
|
||||
let events = [(0, x, y), (btn_mask, x, y), (0, x, y)];
|
||||
|
|
|
|||
Loading…
Reference in a new issue