From 0e1ef1f45fa7fa6ee09a7cd6045a9976b8c678b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 20 Feb 2009 20:00:49 +0000 Subject: [PATCH] added todo testcases for strncat checking --- test/testbufferoverrun.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/testbufferoverrun.cpp b/test/testbufferoverrun.cpp index 42f7a20d5..727520bb1 100644 --- a/test/testbufferoverrun.cpp +++ b/test/testbufferoverrun.cpp @@ -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"