diff options
author | Thanos Makatos <thanos.makatos@nutanix.com> | 2021-01-25 17:33:13 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-25 17:33:13 +0000 |
commit | 915a5b01f34a61cacef5ae5b50a215d13628b8b0 (patch) | |
tree | 6282c7f27790a44ed5787a5f288188e748f41a5e /lib/tran_sock.c | |
parent | 5f2fa524cd587762bd63cfc6d1594dfd4a956272 (diff) | |
download | libvfio-user-915a5b01f34a61cacef5ae5b50a215d13628b8b0.zip libvfio-user-915a5b01f34a61cacef5ae5b50a215d13628b8b0.tar.gz libvfio-user-915a5b01f34a61cacef5ae5b50a215d13628b8b0.tar.bz2 |
don't assume specific message ID when negotiating (#248)
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'lib/tran_sock.c')
-rw-r--r-- | lib/tran_sock.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/tran_sock.c b/lib/tran_sock.c index 3d3b1fc..e798cec 100644 --- a/lib/tran_sock.c +++ b/lib/tran_sock.c @@ -291,7 +291,7 @@ vfu_recv_fds(int sock, struct vfio_user_header *hdr, bool is_reply, } if (is_reply) { - if (hdr->msg_id != *msg_id) { + if (msg_id != NULL && hdr->msg_id != *msg_id) { return -EINVAL; } @@ -309,7 +309,9 @@ vfu_recv_fds(int sock, struct vfio_user_header *hdr, bool is_reply, if (hdr->flags.type != VFIO_USER_F_TYPE_COMMAND) { return -EINVAL; } - *msg_id = hdr->msg_id; + if (msg_id != NULL) { + *msg_id = hdr->msg_id; + } } if (len != NULL && *len > 0 && hdr->msg_size > sizeof *hdr) { @@ -664,7 +666,7 @@ static int negotiate(vfu_ctx_t *vfu_ctx, int sock) { struct vfio_user_version *client_version = NULL; - uint16_t msg_id = 1; + uint16_t msg_id = 0x0bad; int ret; ret = recv_version(vfu_ctx, sock, &msg_id, &client_version); |