Index: src/port/exec.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/port/exec.c,v retrieving revision 1.33 diff -c -r1.33 exec.c *** src/port/exec.c 27 Nov 2004 22:44:15 -0000 1.33 --- src/port/exec.c 3 Dec 2004 01:55:07 -0000 *************** *** 486,511 **** &si, &pi)) { - DWORD bytesread = 0; - /* Successfully started the process */ ! ZeroMemory(line, maxsize); /* Let's see if we can read */ ! if (WaitForSingleObject(childstdoutrddup, 10000) != WAIT_OBJECT_0) { ! /* Got timeout */ ! CloseHandle(pi.hProcess); ! CloseHandle(pi.hThread); ! CloseHandle(childstdoutwr); ! CloseHandle(childstdoutrddup); ! return NULL; } ! /* We try just once */ ! if (ReadFile(childstdoutrddup, line, maxsize, &bytesread, NULL) && ! bytesread > 0) { /* So we read some data */ int len = strlen(line); --- 486,519 ---- &si, &pi)) { /* Successfully started the process */ ! DWORD bytesread = 0; ZeroMemory(line, maxsize); + maxsize--; /* we need to leave room for at least one '\0' */ + /* Let's see if we can read */ ! while (bytesread < maxsize) { ! DWORD tmpbytesread = 0; ! if (WaitForSingleObject(childstdoutrddup, 10000) != WAIT_OBJECT_0) ! { ! /* Got timeout */ ! CloseHandle(pi.hProcess); ! CloseHandle(pi.hThread); ! CloseHandle(childstdoutwr); ! CloseHandle(childstdoutrddup); ! return NULL; ! } ! ! if (ReadFile(childstdoutrddup, &line[bytesread], maxsize - bytesread, &tmpbytesread, NULL) ! && tmpbytesread > 0) ! bytesread += tmpbytesread; ! else ! break; } ! if (bytesread > 0) { /* So we read some data */ int len = strlen(line);