system-exec read: allow 1 byte for null termination -- #7715

This commit is contained in:
Robin Gareus 2019-01-23 12:44:10 +01:00
parent 145d7f8d0a
commit 87602e7fb3
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04

View file

@ -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;