added todo testcases for strncat checking

This commit is contained in:
Daniel Marjamäki 2009-02-20 20:00:49 +00:00
parent 7f94091b9f
commit 0e1ef1f45f
1 changed files with 27 additions and 0 deletions

View File

@ -92,6 +92,9 @@ private:
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"