parent
77095e2b05
commit
53aa2f5982
|
@ -193,7 +193,7 @@ private:
|
||||||
TEST_CASE(array_index_valueflow);
|
TEST_CASE(array_index_valueflow);
|
||||||
|
|
||||||
TEST_CASE(buffer_overrun_1_standard_functions);
|
TEST_CASE(buffer_overrun_1_standard_functions);
|
||||||
TEST_CASE(buffer_overrun_1_posix_functions);
|
TEST_CASE(buffer_overrun_1_posix_functions);
|
||||||
TEST_CASE(buffer_overrun_2_struct);
|
TEST_CASE(buffer_overrun_2_struct);
|
||||||
TEST_CASE(buffer_overrun_3);
|
TEST_CASE(buffer_overrun_3);
|
||||||
TEST_CASE(buffer_overrun_4);
|
TEST_CASE(buffer_overrun_4);
|
||||||
|
@ -2123,66 +2123,66 @@ private:
|
||||||
|
|
||||||
void buffer_overrun_1_posix_functions() {
|
void buffer_overrun_1_posix_functions() {
|
||||||
checkposix("void f(int fd)\n"
|
checkposix("void f(int fd)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" char str[3];\n"
|
" char str[3];\n"
|
||||||
" read(fd, str, 3);\n"
|
" read(fd, str, 3);\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
checkposix("void f(int fd)\n"
|
checkposix("void f(int fd)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" char str[3];\n"
|
" char str[3];\n"
|
||||||
" read(fd, str, 4);\n"
|
" read(fd, str, 4);\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer is accessed out of bounds: str\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer is accessed out of bounds: str\n", errout.str());
|
||||||
|
|
||||||
checkposix("void f(int fd)\n"
|
checkposix("void f(int fd)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" char str[3];\n"
|
" char str[3];\n"
|
||||||
" write(fd, str, 3);\n"
|
" write(fd, str, 3);\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
checkposix("void f(int fd)\n"
|
checkposix("void f(int fd)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" char str[3];\n"
|
" char str[3];\n"
|
||||||
" write(fd, str, 4);\n"
|
" write(fd, str, 4);\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer is accessed out of bounds: str\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer is accessed out of bounds: str\n", errout.str());
|
||||||
|
|
||||||
checkposix("void f()\n"
|
checkposix("void f()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
" long bb[2];\n"
|
" long bb[2];\n"
|
||||||
" write(stdin, bb, sizeof(bb));\n"
|
" write(stdin, bb, sizeof(bb));\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
checkposix("void f()\n"
|
checkposix("void f()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"char str[3];\n"
|
"char str[3];\n"
|
||||||
"recv(s, str, 4, 0);\n"
|
"recv(s, str, 4, 0);\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer is accessed out of bounds: str\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer is accessed out of bounds: str\n", errout.str());
|
||||||
|
|
||||||
checkposix("void f()\n"
|
checkposix("void f()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"char str[3];\n"
|
"char str[3];\n"
|
||||||
"recvfrom(s, str, 4, 0, 0x0, 0x0);\n"
|
"recvfrom(s, str, 4, 0, 0x0, 0x0);\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer is accessed out of bounds: str\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer is accessed out of bounds: str\n", errout.str());
|
||||||
|
|
||||||
checkposix("void f()\n"
|
checkposix("void f()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"char str[3];\n"
|
"char str[3];\n"
|
||||||
"send(s, str, 4, 0);\n"
|
"send(s, str, 4, 0);\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer is accessed out of bounds: str\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer is accessed out of bounds: str\n", errout.str());
|
||||||
|
|
||||||
checkposix("void f()\n"
|
checkposix("void f()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
"char str[3];\n"
|
"char str[3];\n"
|
||||||
"sendto(s, str, 4, 0, 0x0, 0x0);\n"
|
"sendto(s, str, 4, 0, 0x0, 0x0);\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer is accessed out of bounds: str\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer is accessed out of bounds: str\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue