qrexec: add version negotiation

Use lower version from (local, remote).

QubesOS/qubes-issues#4909
This commit is contained in:
Marek Marczykowski-Górecki 2019-04-01 18:14:10 +02:00
parent 3d65517886
commit 1aeec025e0
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -69,6 +69,7 @@ int handle_handshake(libvchan_t *ctrl)
{
struct msg_header hdr;
struct peer_info info;
int actual_version;
/* send own HELLO */
hdr.type = MSG_HELLO;
@ -101,13 +102,14 @@ int handle_handshake(libvchan_t *ctrl)
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);
return -1;
}
return 0;
return actual_version;
}