Skip to content

Commit

Permalink
[client] main: fix buffer overflow due to cursor data size change
Browse files Browse the repository at this point in the history
  • Loading branch information
gnif committed Nov 1, 2021
1 parent 7075fe2 commit a21eee2
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions client/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ int main_cursorThread(void * unused)
LGMP_STATUS status;
LG_RendererCursor cursorType = LG_CURSOR_COLOR;
KVMFRCursor * cursor = NULL;
int cursorSize = 0;

lgWaitEvent(e_startup, TIMEOUT_INFINITE);

Expand Down Expand Up @@ -377,6 +378,12 @@ int main_cursorThread(void * unused)
break;
}

if (cursor && msg.size > cursorSize)
{
free(cursor);
cursor = NULL;
}

/* copy and release the message ASAP */
if (!cursor)
{
Expand All @@ -387,6 +394,7 @@ int main_cursorThread(void * unused)
g_state.state = APP_STATE_SHUTDOWN;
break;
}
cursorSize = msg.size;
}

memcpy(cursor, msg.mem, msg.size);
Expand Down

0 comments on commit a21eee2

Please sign in to comment.