[client/host] added enforcement of KVMFR versioning

This commit is contained in:
Geoffrey McRae
2020-05-17 11:13:08 +10:00
parent dcce288a98
commit c4bf992c0c
5 changed files with 34 additions and 4 deletions

View File

@@ -1446,7 +1446,11 @@ static int lg_run()
LGMP_STATUS status;
while(true)
{
if ((status = lgmpClientInit(state.shm.mem, state.shm.size, &state.lgmp)) == LGMP_OK)
uint32_t udataSize;
KVMFR *udata;
if ((status = lgmpClientInit(state.shm.mem, state.shm.size, &state.lgmp,
&udataSize, (uint8_t **)&udata)) == LGMP_OK)
break;
if (status == LGMP_ERR_INVALID_SESSION || status == LGMP_ERR_INVALID_MAGIC)
@@ -1455,6 +1459,16 @@ static int lg_run()
continue;
}
if (udataSize != sizeof(KVMFR) ||
memcmp(udata->magic, KVMFR_MAGIC, sizeof(udata->magic)) != 0 ||
udata->version != KVMFR_VERSION)
{
DEBUG_ERROR("The host application is not compatible with this client");
DEBUG_ERROR("Expected KVMFR version %d\n", KVMFR_VERSION);
DEBUG_ERROR("This is not a Looking Glass error, do not report this");
return -1;
}
DEBUG_ERROR("lgmpClientInit Failed: %s", lgmpStatusString(status));
return -1;
}