TestDriver.cxx.in: Untrusted array index read.

As reported by Coverity Scan, if the configured file contains a #include,

  Untrusted array index read
  The array index could be controlled by an attacker, leading to reads outside
  the bounds of the array.
  In main: Read from array at index computed using an unscrutinized value from
  an untrusted source (CWE-129)

  CID 1081283 (#1 of 1): Untrusted array index read (TAINTED_SCALAR)
  25. tainted_data: Using tainted variable "testToRun" as an index into an array
  "cmakeGeneratedFunctionMapEntries".
This commit is contained in:
Matt McCormick 2013-10-07 17:10:06 +00:00
parent 1d9af198a8
commit 7eddefd8f1
1 changed files with 7 additions and 0 deletions

View File

@ -137,6 +137,13 @@ int main(int ac, char *av[])
{
int result;
@CMAKE_TESTDRIVER_BEFORE_TESTMAIN@
if (testToRun < 0 || testToRun >= NumTests)
{
printf(
"testToRun was modified by TestDriver code to an invalid value: %3d.\n",
testNum);
return -1;
}
result = (*cmakeGeneratedFunctionMapEntries[testToRun].func)(ac, av);
@CMAKE_TESTDRIVER_AFTER_TESTMAIN@
return result;