TestBufferOverrun: Enable passing tests (#2246)
There are a number of tests and asserts in testbufferoverrun that pass. Enable them to add test coverage.
This commit is contained in:
parent
d82b1b29ce
commit
443fcd2ac4
|
@ -144,7 +144,7 @@ private:
|
|||
TEST_CASE(array_index_vla_for); // #3221: access VLA inside for
|
||||
TEST_CASE(array_index_extern); // FP when using 'extern'. #1684
|
||||
TEST_CASE(array_index_cast); // FP after cast. #2841
|
||||
// TODO string pointer TEST_CASE(array_index_string_literal);
|
||||
TEST_CASE(array_index_string_literal);
|
||||
TEST_CASE(array_index_same_struct_and_var_name); // #4751 - not handled well when struct name and var name is same
|
||||
TEST_CASE(array_index_valueflow);
|
||||
TEST_CASE(array_index_valueflow_pointer);
|
||||
|
@ -174,7 +174,7 @@ private:
|
|||
TEST_CASE(buffer_overrun_30); // #6367
|
||||
TEST_CASE(buffer_overrun_31);
|
||||
TEST_CASE(buffer_overrun_errorpath);
|
||||
// TODO CTU TEST_CASE(buffer_overrun_bailoutIfSwitch); // ticket #2378 : bailoutIfSwitch
|
||||
TEST_CASE(buffer_overrun_bailoutIfSwitch); // ticket #2378 : bailoutIfSwitch
|
||||
// TODO TEST_CASE(buffer_overrun_function_array_argument);
|
||||
// TODO alloca TEST_CASE(possible_buffer_overrun_1); // #3035
|
||||
TEST_CASE(buffer_overrun_readSizeFromCfg);
|
||||
|
@ -1059,7 +1059,7 @@ private:
|
|||
" }\n"
|
||||
" int m_x[1];\n"
|
||||
"};");
|
||||
// TODO [1] ASSERT_EQUALS("[test.cpp:7]: (error) Array 'm_x[1]' accessed at index 1, which is out of bounds.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:7]: (error) Array 'm_x[1]' accessed at index 1, which is out of bounds.\n", errout.str());
|
||||
}
|
||||
|
||||
void array_index_33() {
|
||||
|
@ -1127,14 +1127,14 @@ private:
|
|||
" struct Struct { unsigned m_Var[1]; } s;\n"
|
||||
" s.m_Var[1] = 1;\n"
|
||||
"}");
|
||||
// TODO ASSERT_EQUALS("[test.cpp:3]: (error) Array 's.m_Var[1]' accessed at index 1, which is out of bounds.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Array 's.m_Var[1]' accessed at index 1, which is out of bounds.\n", errout.str());
|
||||
|
||||
check("struct Struct { unsigned m_Var[1]; };\n"
|
||||
"void f() {\n"
|
||||
" struct Struct s;\n"
|
||||
" s.m_Var[1] = 1;\n"
|
||||
"}");
|
||||
// TODO ASSERT_EQUALS("[test.cpp:4]: (error) Array 's.m_Var[1]' accessed at index 1, which is out of bounds.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Array 's.m_Var[1]' accessed at index 1, which is out of bounds.\n", errout.str());
|
||||
|
||||
check("struct Struct { unsigned m_Var[1]; };\n"
|
||||
"void f() {\n"
|
||||
|
@ -1376,7 +1376,7 @@ private:
|
|||
" int * p = &ab[10].a[0]; \n"
|
||||
" return 0;\n"
|
||||
"}");
|
||||
// TODO ASSERT_EQUALS("[test.cpp:4]: (error) Array 'ab[1]' accessed at index 10, which is out of bounds.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Array 'ab[1]' accessed at index 10, which is out of bounds.\n", errout.str());
|
||||
}
|
||||
|
||||
void array_index_44() { // #3979 (false positive)
|
||||
|
@ -1691,7 +1691,7 @@ private:
|
|||
" char data[8][4];\n"
|
||||
" data[5][-1] = 0;\n"
|
||||
"}");
|
||||
// TODO multidim ASSERT_EQUALS("[test.cpp:4]: (error) Array index -1 is out of bounds.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Array 'data[8][4]' accessed at index data[*][-1], which is out of bounds.\n", errout.str());
|
||||
|
||||
// #1614 - negative index is ok for pointers
|
||||
check("void foo(char *p)\n"
|
||||
|
@ -2570,7 +2570,7 @@ private:
|
|||
" char a[10];\n"
|
||||
" f1(a);"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:3]: (error) Array 'a[10]' accessed at index 100, which is out of bounds.\n", errout.str());
|
||||
TODO_ASSERT_EQUALS("[test.cpp:8] -> [test.cpp:3]: (error) Array 'a[10]' accessed at index 100, which is out of bounds.\n", "", errout.str());
|
||||
}
|
||||
|
||||
void buffer_overrun_function_array_argument() {
|
||||
|
@ -2734,7 +2734,7 @@ private:
|
|||
" if (cond) x = \"abcde\";\n"
|
||||
" return x[20];\n" // <- array index out of bounds when x is "abcde"
|
||||
"}");
|
||||
// TODO ASSERT_EQUALS("[test.cpp:4]: (error) Array 'x[6]' accessed at index 20, which is out of bounds.\n", errout.str());
|
||||
ASSERT_EQUALS("[test.cpp:4]: (error) Array 'x[6]' accessed at index 20, which is out of bounds.\n", errout.str());
|
||||
}
|
||||
|
||||
void pointer_out_of_bounds_1() {
|
||||
|
@ -3259,7 +3259,7 @@ private:
|
|||
" char b[5][6];\n"
|
||||
" mymemset(b, 0, 5 * 6);\n"
|
||||
"}", settings);
|
||||
// TODO ASSERT_EQUALS("", errout.str());
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("int main() {\n"
|
||||
" char b[5][6];\n"
|
||||
|
@ -3267,6 +3267,12 @@ private:
|
|||
"}", settings);
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Buffer is accessed out of bounds: b\n", errout.str());
|
||||
|
||||
check("int main() {\n"
|
||||
" char b[5][6];\n"
|
||||
" mymemset(b, 0, 31);\n"
|
||||
"}", settings);
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Buffer is accessed out of bounds: b\n", errout.str());
|
||||
|
||||
// #4968 - not standard function
|
||||
check("void f() {\n"
|
||||
" char str[3];\n"
|
||||
|
|
Loading…
Reference in New Issue