BUG OF THE MONTH | Array index out of bounds
V557 Array overrun is possible. The value of ‘i’ index could reach 8. rl.cpp 2375
enum TestInfoKind::_TIK_COUNT = 9 const char * const TestInfoEnvLstFmt[] = { " TESTFILE=\"%s\"", " BASELINE=\"%s\"", " CFLAGS=\"%s\"", " LFLAGS=\"%s\"", NULL, NULL, NULL, NULL }; void WriteEnvLst ( Test * pDir, TestList * pTestList ) { .... // print the other TIK_* for(int i=0;i < _TIK_COUNT; i++) { if (variants->testInfo.data[i] && TestInfoEnvLstFmt[i]){ LstFilesOut->Add(TestInfoEnvLstFmt[i], variants->testInfo.data[i]); } .... } .... }
The analyzer detected that array index is out of bounds. The things is that the for() loop performs 9 iterations, but there are only 8 elements in the TestInfoEnvLstFmt[] array.
Please click here to see more bugs from this project.