qrexec: add version negotiation

Use lower version from (local, remote).

QubesOS/qubes-issues#4909
This commit is contained in:
Marek Marczykowski-Górecki 2019-03-31 19:23:40 +02:00
parent b6e3f360c9
commit 61ec339c2d
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -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;