[Spice-commits] vdagent/vdagent.cpp
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri May 15 10:50:43 UTC 2020
vdagent/vdagent.cpp | 34 ++++++++++++++++++++++++----------
1 file changed, 24 insertions(+), 10 deletions(-)
New commits:
commit 0fe97cc05aee4669b446ac85e19066c4771860ff
Author: Frediano Ziglio <freddy77 at gmail.com>
Date: Thu May 14 09:22:48 2020 +0100
Use final capabilities to check client messages
The client is sending messages that are compatible with agent
capabilities but also encoded with capabilities it knows of so to
check them we need to consider final capabilities, not client ones.
This fixes a regression introduced with
"vdagent: Reuse agent_check_message" where some messages were wrongly
interpreted as wrong (particularly some clipboard messages).
Signed-off-by: Frediano Ziglio <freddy77 at gmail.com>
Acked-by: Jakub Janků <jjanku at redhat.com>
diff --git a/vdagent/vdagent.cpp b/vdagent/vdagent.cpp
index 3e100f8..35a7c95 100644
--- a/vdagent/vdagent.cpp
+++ b/vdagent/vdagent.cpp
@@ -28,6 +28,7 @@
#include <queue>
#include <set>
#include <vector>
+#include <array>
#define VD_AGENT_LOG_PATH TEXT("%svdagent.log")
#define VD_AGENT_WINCLASS_NAME TEXT("VDAGENT")
@@ -161,6 +162,7 @@ private:
int32_t _max_clipboard;
std::vector<uint32_t> _client_caps;
+ std::array<uint32_t, VD_AGENT_CAPS_SIZE> _final_caps;
std::set<uint32_t> _grab_types;
@@ -813,6 +815,18 @@ void VDAgent::load_display_setting()
_display_setting.load();
}
+static const uint16_t supported_caps[] = {
+ VD_AGENT_CAP_MOUSE_STATE,
+ VD_AGENT_CAP_MONITORS_CONFIG,
+ VD_AGENT_CAP_REPLY,
+ VD_AGENT_CAP_DISPLAY_CONFIG,
+ VD_AGENT_CAP_CLIPBOARD_BY_DEMAND,
+ VD_AGENT_CAP_SPARSE_MONITORS_CONFIG,
+ VD_AGENT_CAP_GUEST_LINEEND_CRLF,
+ VD_AGENT_CAP_MAX_CLIPBOARD,
+ VD_AGENT_CAP_FILE_XFER_DETAILED_ERRORS,
+};
+
bool VDAgent::send_announce_capabilities(bool request)
{
DWORD msg_size;
@@ -838,15 +852,9 @@ bool VDAgent::send_announce_capabilities(bool request)
caps = (VDAgentAnnounceCapabilities*)caps_msg->data;
caps->request = request;
memset(caps->caps, 0, VD_AGENT_CAPS_BYTES);
- VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_MOUSE_STATE);
- VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_MONITORS_CONFIG);
- VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_REPLY);
- VD_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_DISPLAY_CONFIG);
- 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_AGENT_SET_CAPABILITY(caps->caps, VD_AGENT_CAP_FILE_XFER_DETAILED_ERRORS);
+ for (auto cap : supported_caps) {
+ VD_AGENT_SET_CAPABILITY(caps->caps, cap);
+ }
vd_printf("Sending capabilities:");
for (uint32_t i = 0 ; i < caps_size; ++i) {
vd_printf("%X", caps->caps[i]);
@@ -866,6 +874,12 @@ bool VDAgent::handle_announce_capabilities(const VDAgentAnnounceCapabilities* an
}
_client_caps.assign(announce_capabilities->caps, announce_capabilities->caps + caps_size);
+ for (auto cap : supported_caps) {
+ if (VD_AGENT_HAS_CAPABILITY(announce_capabilities->caps, caps_size, cap)) {
+ VD_AGENT_SET_CAPABILITY(_final_caps.data(), cap);
+ }
+ }
+
if (has_capability(VD_AGENT_CAP_MONITORS_CONFIG_POSITION))
_desktop_layout->set_position_configurable(true);
if (announce_capabilities->request) {
@@ -1253,7 +1267,7 @@ void VDAgent::dispatch_message(VDAgentMessage* msg, uint32_t port)
bool res = true;
// check message
- switch (agent_check_message(msg, msg->data, _client_caps.data(), _client_caps.size())) {
+ switch (agent_check_message(msg, msg->data, _final_caps.data(), _final_caps.size())) {
case AGENT_CHECK_WRONG_PROTOCOL_VERSION:
vd_printf("Invalid protocol %u", msg->protocol);
_running = false;
More information about the Spice-commits
mailing list