Skip to content

Commit

Permalink
[client] updated client to support new KVMFR cursor dataPos field
Browse files Browse the repository at this point in the history
  • Loading branch information
gnif committed Dec 14, 2017
1 parent 110aced commit 8ae9f84
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions client/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,19 @@ int renderThread(void * unused)
__sync_or_and_fetch(&state.shm->flags, KVMFR_HEADER_FLAG_READY);

// check the header's magic and version are valid
if (
memcmp(header.magic, KVMFR_HEADER_MAGIC, sizeof(KVMFR_HEADER_MAGIC)) != 0 ||
header.version != KVMFR_HEADER_VERSION
){
if (memcmp(header.magic, KVMFR_HEADER_MAGIC, sizeof(KVMFR_HEADER_MAGIC)) != 0)
{
usleep(1000);
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 (header.flags & KVMFR_HEADER_FLAG_FRAME)
{
Expand Down Expand Up @@ -281,13 +286,22 @@ int renderThread(void * unused)

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(
state.lgrData,
c,
header.cursor.w,
header.cursor.h,
header.cursor.pitch,
header.cursor.shape
data
))
{
DEBUG_ERROR("Failed to update mouse shape");
Expand Down

0 comments on commit 8ae9f84

Please sign in to comment.