diff options
Diffstat (limited to 'vdagent')
-rw-r--r-- | vdagent/vdagent.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp index 3131376..15216d9 100644 --- a/vdagent/vdagent.cpp +++ b/vdagent/vdagent.cpp @@ -92,6 +92,7 @@ private: bool handle_clipboard_request(VDAgentClipboardRequest* clipboard_request); void handle_clipboard_release(); bool handle_display_config(VDAgentDisplayConfig* display_config, uint32_t port); + bool handle_max_clipboard(VDAgentMaxClipboard *msg, uint32_t size); void handle_chunk(VDIChunk* chunk); void on_clipboard_grab(); void on_clipboard_request(UINT format); @@ -164,6 +165,7 @@ private: bool _display_setting_initialized; bool _logon_occured; + int32_t _max_clipboard; uint32_t *_client_caps; uint32_t _client_caps_size; @@ -210,6 +212,7 @@ VDAgent::VDAgent() , _write_pos (0) , _logon_desktop (false) , _display_setting_initialized (false) + , _max_clipboard (-1) , _client_caps (NULL) , _client_caps_size (0) , _log (NULL) @@ -799,6 +802,7 @@ bool VDAgent::send_announce_capabilities(bool request) VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_CLIPBOARD_BY_DEMAND); VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_SPARSE_MONITORS_CONFIG); VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_GUEST_LINEEND_CRLF); + VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_MAX_CLIPBOARD); vd_printf("Sending capabilities:"); for (uint32_t i = 0 ; i < caps_size; ++i) { vd_printf("%X", caps->caps[i]); @@ -874,6 +878,18 @@ bool VDAgent::handle_display_config(VDAgentDisplayConfig* display_config, uint32 return true; } +bool VDAgent::handle_max_clipboard(VDAgentMaxClipboard *msg, uint32_t size) +{ + if (size != sizeof(VDAgentMaxClipboard)) { + vd_printf("VDAgentMaxClipboard: unexpected msg size %u (expected %u)", + size, sizeof(VDAgentMaxClipboard)); + return false; + } + vd_printf("Set max clipboard size: %d", msg->max); + _max_clipboard = msg->max; + return true; +} + #define MIN(a, b) ((a) > (b) ? (b) : (a)) bool VDAgent::write_clipboard(VDAgentMessage* msg, uint32_t size) @@ -1109,6 +1125,11 @@ bool VDAgent::handle_clipboard_request(VDAgentClipboardRequest* clipboard_reques vd_printf("clipboard is empty"); goto handle_clipboard_request_fail; } + if ((_max_clipboard != -1) && (new_size > _max_clipboard)) { + vd_printf("clipboard is too large (%ld > %d), discarding", + new_size, _max_clipboard); + goto handle_clipboard_request_fail; + } msg_size = sizeof(VDAgentMessage) + sizeof(VDAgentClipboard) + new_size; msg = (VDAgentMessage*)new uint8_t[msg_size]; @@ -1262,6 +1283,9 @@ void VDAgent::dispatch_message(VDAgentMessage* msg, uint32_t port) vd_printf("Client disconnected, agent to be restarted"); set_control_event(CONTROL_STOP); break; + case VD_AGENT_MAX_CLIPBOARD: + res = handle_max_clipboard((VDAgentMaxClipboard*)msg->data, msg->size); + break; default: vd_printf("Unsupported message type %u size %u", msg->type, msg->size); } |