forked from Public-Mirror/Textractor
fix buffer overrun
This commit is contained in:
parent
943e53e9a2
commit
bb86bde8a5
@ -94,9 +94,10 @@ DWORD WINAPI Pipe(LPVOID)
|
|||||||
void TextOutput(ThreadParam tp, BYTE* text, int len)
|
void TextOutput(ThreadParam tp, BYTE* text, int len)
|
||||||
{
|
{
|
||||||
if (len < 0) return;
|
if (len < 0) return;
|
||||||
|
if (len > PIPE_BUFFER_SIZE - sizeof(ThreadParam)) len = PIPE_BUFFER_SIZE - sizeof(ThreadParam);
|
||||||
BYTE buffer[PIPE_BUFFER_SIZE] = {};
|
BYTE buffer[PIPE_BUFFER_SIZE] = {};
|
||||||
*(ThreadParam*)buffer = tp;
|
*(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);
|
WriteFile(hookPipe, buffer, sizeof(ThreadParam) + len, &DUMMY, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user