added TODO testcase for checking fwrite() and fread() check for buffer overrun
This commit is contained in:
parent
5aa88ee5a2
commit
2e11805c1a
|
@ -1078,6 +1078,15 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer access out-of-bounds\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer access out-of-bounds\n", errout.str());
|
||||||
|
|
||||||
|
// fread
|
||||||
|
check("void f(FILE* fd)\n"
|
||||||
|
"{\n"
|
||||||
|
"unsigned int i = 3;\n"
|
||||||
|
"char str[i];\n"
|
||||||
|
"fread(str,sizeof(char),i+1,fd);\n"
|
||||||
|
"}\n");
|
||||||
|
TODO_ASSERT_EQUALS("[test.cpp:5]: (error) Buffer access out-of-bounds\n", errout.str());
|
||||||
|
|
||||||
check("void f(FILE* fd)\n"
|
check("void f(FILE* fd)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"char str[3*sizeof(char)];\n"
|
"char str[3*sizeof(char)];\n"
|
||||||
|
@ -1093,6 +1102,14 @@ private:
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer access out-of-bounds\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer access out-of-bounds\n", errout.str());
|
||||||
|
|
||||||
|
check("void f(FILE* fd)\n"
|
||||||
|
"{\n"
|
||||||
|
"unsigned int i = 3;\n"
|
||||||
|
"char str[i];\n"
|
||||||
|
"fwrite(str,sizeof(char),i+1,fd);\n"
|
||||||
|
"}\n");
|
||||||
|
TODO_ASSERT_EQUALS("[test.cpp:5]: (error) Buffer access out-of-bounds\n", errout.str());
|
||||||
|
|
||||||
check("void f(FILE* fd)\n"
|
check("void f(FILE* fd)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"char str[3*sizeof(char)];\n"
|
"char str[3*sizeof(char)];\n"
|
||||||
|
|
Loading…
Reference in New Issue