Avoid a possible buffer overflow in winpty-debugserver.exe

Also: use fwrite directly instead of printf; maybe it's a bit faster.
This commit is contained in:
Ryan Prichard 2015-12-24 21:25:06 -06:00
parent 6c8b7effe5
commit 6720daa07a

View File

@ -37,7 +37,7 @@ int main() {
10 * 1000,
NULL);
char msgBuffer[MSG_SIZE];
char msgBuffer[MSG_SIZE + 1];
while (true) {
if (!ConnectNamedPipe(serverPipe, NULL)) {
@ -52,8 +52,8 @@ int main() {
DisconnectNamedPipe(serverPipe);
continue;
}
msgBuffer[bytesRead] = '\0';
printf("%s\n", msgBuffer);
msgBuffer[bytesRead] = '\n';
fwrite(msgBuffer, 1, bytesRead + 1, stdout);
fflush(stdout);
DWORD bytesWritten = 0;