From 61ec339c2de708b3c05e9c3b2bf1793c44a94c63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Sun, 31 Mar 2019 19:23:40 +0200 Subject: [PATCH] qrexec: add version negotiation Use lower version from (local, remote). QubesOS/qubes-issues#4909 --- qrexec/qrexec-daemon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qrexec/qrexec-daemon.c b/qrexec/qrexec-daemon.c index 71df964..6c8faf2 100644 --- a/qrexec/qrexec-daemon.c +++ b/qrexec/qrexec-daemon.c @@ -186,6 +186,7 @@ int handle_agent_hello(libvchan_t *ctrl, const char *domain_name) { struct msg_header hdr; struct peer_info info; + int actual_version; if (libvchan_recv(ctrl, &hdr, sizeof(hdr)) != sizeof(hdr)) { fprintf(stderr, "Failed to read agent HELLO hdr\n"); @@ -202,7 +203,9 @@ int handle_agent_hello(libvchan_t *ctrl, const char *domain_name) return -1; } - if (info.version != QREXEC_PROTOCOL_VERSION) { + actual_version = info.version < QREXEC_PROTOCOL_VERSION ? info.version : QREXEC_PROTOCOL_VERSION; + + if (actual_version != QREXEC_PROTOCOL_VERSION) { fprintf(stderr, "Incompatible agent protocol version (remote %d, local %d)\n", info.version, QREXEC_PROTOCOL_VERSION); incompatible_protocol_error_message(domain_name, info.version); return -1;