[client] updated client to support new KVMFR cursor dataPos field

This commit is contained in:
Geoffrey McRae 2017-12-15 10:51:40 +11:00
parent 110aced7d1
commit 8ae9f8464b

View File

@ -169,14 +169,19 @@ int renderThread(void * unused)
__sync_or_and_fetch(&state.shm->flags, KVMFR_HEADER_FLAG_READY); __sync_or_and_fetch(&state.shm->flags, KVMFR_HEADER_FLAG_READY);
// check the header's magic and version are valid // check the header's magic and version are valid
if ( if (memcmp(header.magic, KVMFR_HEADER_MAGIC, sizeof(KVMFR_HEADER_MAGIC)) != 0)
memcmp(header.magic, KVMFR_HEADER_MAGIC, sizeof(KVMFR_HEADER_MAGIC)) != 0 || {
header.version != KVMFR_HEADER_VERSION
){
usleep(1000); usleep(1000);
continue; continue;
} }
if (header.version != KVMFR_HEADER_VERSION)
{
DEBUG_ERROR("KVMFR version missmatch, expected %u but got %u", KVMFR_HEADER_VERSION, header.version);
DEBUG_ERROR("This is not a bug, ensure you have the right version of looking-glass-host.exe on the guest");
break;
}
// if we have a frame // if we have a frame
if (header.flags & KVMFR_HEADER_FLAG_FRAME) if (header.flags & KVMFR_HEADER_FLAG_FRAME)
{ {
@ -281,13 +286,22 @@ int renderThread(void * unused)
if (state.lgr) if (state.lgr)
{ {
// check the data position is sane
const uint64_t dataSize = header.cursor.h * header.cursor.pitch;
if (header.cursor.dataPos + dataSize > state.shmSize)
{
DEBUG_ERROR("The guest sent an invalid mouse dataPos");
break;
}
const uint8_t * data = (const uint8_t *)state.shm + header.cursor.dataPos;
if (!state.lgr->on_mouse_shape( if (!state.lgr->on_mouse_shape(
state.lgrData, state.lgrData,
c, c,
header.cursor.w, header.cursor.w,
header.cursor.h, header.cursor.h,
header.cursor.pitch, header.cursor.pitch,
header.cursor.shape data
)) ))
{ {
DEBUG_ERROR("Failed to update mouse shape"); DEBUG_ERROR("Failed to update mouse shape");