From 94d439e5c3aa388a2cf98a26ad1a4be5d7563763 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 30 Nov 2021 19:05:32 +0300 Subject: [PATCH] Fix memory corruption with UTF-8 strings over 32 bytes --- src/InputStream.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/InputStream.c b/src/InputStream.c index 92c771f..d795b37 100644 --- a/src/InputStream.c +++ b/src/InputStream.c @@ -17,7 +17,12 @@ static PLT_THREAD inputSendThread; // Contains input stream packets typedef struct _PACKET_HOLDER { + LINKED_BLOCKING_QUEUE_ENTRY entry; int packetLength; + + // The union must be the last member since we abuse the NV_UNICODE_PACKET + // text field to store variable length data which gets split before being + // sent to the host. union { NV_INPUT_HEADER header; NV_KEYBOARD_PACKET keyboard; @@ -30,7 +35,6 @@ typedef struct _PACKET_HOLDER { NV_HAPTICS_PACKET haptics; NV_UNICODE_PACKET unicode; } packet; - LINKED_BLOCKING_QUEUE_ENTRY entry; } PACKET_HOLDER, *PPACKET_HOLDER; // Initializes the input stream