@@ -209,13 +209,6 @@ class TestBufferOverrun : public TestFixture {
209209 TEST_CASE (pointer_out_of_bounds_2);
210210 TEST_CASE (pointer_out_of_bounds_sub);
211211
212- TEST_CASE (snprintf1);
213- TEST_CASE (snprintf2);
214- TEST_CASE (snprintf4);
215- TEST_CASE (snprintf5);
216- TEST_CASE (snprintf6);
217- TEST_CASE (snprintf7);
218-
219212 TEST_CASE (strncat1);
220213 TEST_CASE (strncat2);
221214 TEST_CASE (strncat3);
@@ -2893,91 +2886,6 @@ class TestBufferOverrun : public TestFixture {
28932886 ASSERT_EQUALS (" [test.cpp:4]: (portability) Undefined behaviour, when 'i' is -20 the pointer arithmetic 'x-i' is out of bounds.\n " , errout.str ());
28942887 }
28952888
2896- void snprintf1 () {
2897- check (" void f()\n "
2898- " {\n "
2899- " char str[5];\n "
2900- " snprintf(str, 10, \" %s\" , \" abc\" );\n "
2901- " }" );
2902- ASSERT_EQUALS (" [test.cpp:4]: (error) snprintf size is out of bounds: Supplied size 10 is larger than actual size 5.\n " , errout.str ());
2903- }
2904-
2905- void snprintf2 () {
2906- check (" void f()\n "
2907- " {\n "
2908- " char str[5];\n "
2909- " snprintf(str, 5, \" %s\" , \" abc\" );\n "
2910- " }" );
2911- ASSERT_EQUALS (" " , errout.str ());
2912- }
2913-
2914- void snprintf4 () {
2915- check (" void f(int x)\n "
2916- " {\n "
2917- " char str[5];\n "
2918- " snprintf(str, 8 - x, \" abcdefghijkl\" );\n "
2919- " }" );
2920- ASSERT_EQUALS (" " , errout.str ());
2921- }
2922-
2923- void snprintf5 () {
2924- check (" struct Foo { char a[1]; };\n "
2925- " void f()\n "
2926- " {\n "
2927- " struct Foo x;\n "
2928- " snprintf(x.a, 2, \" aa\" );\n "
2929- " }" );
2930- ASSERT_EQUALS (" [test.cpp:5]: (error) snprintf size is out of bounds: Supplied size 2 is larger than actual size 1.\n " , errout.str ());
2931-
2932- // This is out of bounds if 'sizeof(ABC)' is 1 (No padding)
2933- check (" struct Foo { char a[1]; };\n "
2934- " void f()\n "
2935- " {\n "
2936- " struct Foo *x = malloc(sizeof(Foo));\n "
2937- " snprintf(x.a, 2, \" aa\" );\n "
2938- " free(x);\n "
2939- " }" );
2940- TODO_ASSERT_EQUALS (" error" , " " , errout.str ());
2941-
2942- check (" struct Foo { char a[1]; };\n "
2943- " void f()\n "
2944- " {\n "
2945- " struct Foo *x = malloc(sizeof(Foo) + 10);\n "
2946- " snprintf(x.a, 2, \" aa\" );\n "
2947- " free(x);\n "
2948- " }" );
2949- ASSERT_EQUALS (" " , errout.str ());
2950- }
2951-
2952- void snprintf6 () {
2953- check (" struct Foo { char a[3]; };\n "
2954- " void f()\n "
2955- " {\n "
2956- " struct Foo x;\n "
2957- " snprintf(x.a, 2, \" aa\" );\n "
2958- " }" );
2959- ASSERT_EQUALS (" " , errout.str ());
2960- }
2961-
2962- void snprintf7 () {
2963- check (" void x() {\n "
2964- " sal_Char pString[1024];\n "
2965- " snprintf(pString, 1024, \" ab\" );\n "
2966- " }" );
2967- ASSERT_EQUALS (" " , errout.str ());
2968-
2969- // #6141 FP: Unknown type is assumed to have size 0
2970- check (" typedef struct {\n "
2971- " CHAR s[42];\n "
2972- " } sct_t;\n "
2973- " void foo() {\n "
2974- " sct_t p;\n "
2975- " snprintf(p.s, 42, \" abcdef\" );\n "
2976- " }\n " );
2977- ASSERT_EQUALS (" " , errout.str ());
2978-
2979- }
2980-
29812889 void strncat1 () {
29822890 checkstd (" void f(char *a, char *b) {\n "
29832891 " char str[16];\n "
0 commit comments