From 87602e7fb368496cebd75ebb4985f488f22878b5 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 23 Jan 2019 12:44:10 +0100 Subject: [PATCH] system-exec read: allow 1 byte for null termination -- #7715 --- libs/pbd/system_exec.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/pbd/system_exec.cc b/libs/pbd/system_exec.cc index 6f86e5edb9..81f54c198c 100644 --- a/libs/pbd/system_exec.cc +++ b/libs/pbd/system_exec.cc @@ -613,7 +613,7 @@ SystemExec::output_interposer() if (bytesAvail < 1) {Sleep(500); printf("N/A\n"); continue;} #endif if (stdoutP[0] == INVALID_HANDLE_VALUE) break; - if (!ReadFile(stdoutP[0], data, BUFSIZ, &bytesRead, 0)) { + if (!ReadFile(stdoutP[0], data, BUFSIZ - 1, &bytesRead, 0)) { DWORD err = GetLastError(); if (err == ERROR_IO_PENDING) continue; break; @@ -964,7 +964,7 @@ SystemExec::output_interposer() ioctl(rfd, FIONBIO, &l); // set non-blocking I/O for (;fcntl(rfd, F_GETFL)!=-1;) { - r = read(rfd, buf, sizeof(buf)); + r = read(rfd, buf, BUFSIZ - 1); if (r < 0 && (errno == EINTR || errno == EAGAIN)) { fd_set rfds; struct timeval tv;