From 79ef34ef7fde1d31548f596014341f2a1dc9f6f3 Mon Sep 17 00:00:00 2001 From: Rolf Eike Beer <eike@sf-mail.de> Date: Tue, 8 Jan 2013 18:13:14 +0100 Subject: [PATCH] SystemInformation: fix calling kwsysProcess_WaitForData() kwsysProcess_WaitForData() may return kwsysProcess_Pipe_Timeout, which is 255. The current check would take that as sign of success and read invalid data or even crash. Change-Id: I148f5d435a088cb3814f513cce4f13e5358e5730 --- SystemInformation.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SystemInformation.cxx b/SystemInformation.cxx index 0460b29..744d5ec 100644 --- a/SystemInformation.cxx +++ b/SystemInformation.cxx @@ -4059,8 +4059,10 @@ kwsys_stl::string SystemInformationImplementation::RunProcess(kwsys_stl::vector< char* data = NULL; int length; double timeout = 255; + int pipe; // pipe id as returned by kwsysProcess_WaitForData() - while(kwsysProcess_WaitForData(gp,&data,&length,&timeout)) // wait for 1s + while( ( pipe = kwsysProcess_WaitForData(gp,&data,&length,&timeout), + (pipe == kwsysProcess_Pipe_STDOUT || pipe == kwsysProcess_Pipe_STDERR) ) ) // wait for 1s { for(int i=0;i<length;i++) { -- GitLab