fix buffer overrun

This commit is contained in:
Akash Mozumdar 2018-11-27 15:56:28 -05:00
parent 943e53e9a2
commit bb86bde8a5

View File

@ -94,9 +94,10 @@ DWORD WINAPI Pipe(LPVOID)
void TextOutput(ThreadParam tp, BYTE* text, int len)
{
if (len < 0) return;
if (len > PIPE_BUFFER_SIZE - sizeof(ThreadParam)) len = PIPE_BUFFER_SIZE - sizeof(ThreadParam);
BYTE buffer[PIPE_BUFFER_SIZE] = {};
*(ThreadParam*)buffer = tp;
memcpy_s(buffer + sizeof(ThreadParam), sizeof(buffer) - sizeof(ThreadParam), text, len);
memcpy(buffer + sizeof(ThreadParam), text, len);
WriteFile(hookPipe, buffer, sizeof(ThreadParam) + len, &DUMMY, nullptr);
}