added todo testcases for strncat checking
This commit is contained in:
parent
7f94091b9f
commit
0e1ef1f45f
|
@ -91,6 +91,9 @@ private:
|
|||
TEST_CASE(snprintf1);
|
||||
TEST_CASE(snprintf2);
|
||||
TEST_CASE(snprintf3);
|
||||
|
||||
// TODO TEST_CASE(strncat1);
|
||||
// TODO TEST_CASE(strncat2);
|
||||
|
||||
TEST_CASE(varid1);
|
||||
TEST_CASE(varid2);
|
||||
|
@ -466,6 +469,30 @@ private:
|
|||
|
||||
|
||||
|
||||
void strncat1()
|
||||
{
|
||||
check("void f()\n"
|
||||
"{\n"
|
||||
" char str[10];\n"
|
||||
" strncpy(str, a, 5);\n"
|
||||
" strncat(str, b, 5);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string("[test.cpp:5]: (error) possible buffer overrun"), errout.str());
|
||||
}
|
||||
|
||||
void strncat2()
|
||||
{
|
||||
check("void f()\n"
|
||||
"{\n"
|
||||
" char str[5];\n"
|
||||
" strncat(str, a, 5);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS(std::string("[test.cpp:4]: (error) dangerous usage of strncat. If str is nonempty there will be a buffer overrun\n"), errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void varid1()
|
||||
{
|
||||
check("void foo()\n"
|
||||
|
|
Loading…
Reference in New Issue