Index: lib/Fuzzer/FuzzerUtil.cpp =================================================================== --- lib/Fuzzer/FuzzerUtil.cpp +++ lib/Fuzzer/FuzzerUtil.cpp @@ -207,11 +207,22 @@ bool ExecuteCommandAndReadOutput(const std::string &Command, std::string *Out) { FILE *Pipe = OpenProcessPipe(Command.c_str(), "r"); - if (!Pipe) return false; + if (!Pipe) { + Printf("OpenProcessPipe failed with %d.\n", errno); + return false; + } + char Buff[1024]; size_t N; - while ((N = fread(Buff, 1, sizeof(Buff), Pipe)) > 0) + while ((N = fread(Buff, 1, sizeof(Buff), Pipe)) == sizeof(Buff)) Out->append(Buff, N); + if (ferror(Pipe)) { + Printf("Failed to read opened process pipe.\n"); + return false; + } + // Add last data read. + Out->append(Buff, N); + return true; }