From 8ae9f8464b37f72ebcaa78d7c02c884068786ce5 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Fri, 15 Dec 2017 10:51:40 +1100 Subject: [PATCH] [client] updated client to support new KVMFR cursor dataPos field --- client/main.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/client/main.c b/client/main.c index ccc7a875..357dc17a 100644 --- a/client/main.c +++ b/client/main.c @@ -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) { @@ -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");