There is a bug in cmParseBlanketJSCoverage.cxx
The bug is in the code
std::string getValue(std::string const& line, int type)
{
size_t begIndex;
size_t endIndex;
endIndex = line.rfind(',');
begIndex = line.find_first_of(':');
if (type == 0) {
// A unique substring to remove the extra characters
// around the files name in the JSON (extra " and ,)
std::string foundFileName =
line.substr(begIndex + 3, endIndex - (begIndex + 4));
return foundFileName;
}
return line.substr(begIndex);
}
Not check return from line.find_first_of(':')
; when not finding ':',it will return -1
and begIndex
will be a MAX_NUM.
and line.substr(begIndex)
will be out-of-range.
POC
cd cmake_3.14.3/Testing/JavascriptCoverage
Then put Output_poc.json
to replace 'Output.json',then run command cmake_3.14.3/bin/ctest -T Coverage --debug
it will output the issue:
/usr1/work/zktest/projs/cmake14/Source/CTest/cmParseBlanketJSCoverage.cxx:137 Parsing /usr1/work/zktest/projs/cmake14/Testing/JavascriptCoverage/output.json
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::substr: __pos (which is 18446744073709551615) > this->size() (which is 32)
Aborted
from: Eagleye team Cheng Renfeng. Zhou Kai. Cheng Xiaoyan.