Fixed #909 (improve check: out of bounds of memchr function and out of bounds check)

This commit is contained in:
Marek Zmysłowski 2011-11-27 07:54:52 +01:00 committed by Daniel Marjamäki
parent 2d3a232ef6
commit e0b50719f4
2 changed files with 6 additions and 4 deletions

View File

@ -530,6 +530,7 @@ void CheckBufferOverrun::checkFunctionParameter(const Token &tok, unsigned int p
total_size["memcmp"] = 3;
total_size["memcpy"] = 3;
total_size["memmove"] = 3;
total_size["memchr"] = 3;
if (par == 1) {
// reading from array

View File

@ -2718,13 +2718,14 @@ private:
"}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Buffer access out-of-bounds: a\n", errout.str());
// When this TODO assertion works, ticket #909 can probably be closed
// Ticket #909
check("void f()\n"
"{\n"
" char a[5], b[50];\n"
" memchr(a, b, 10);\n"
" char * pch;\n"
" char str[] = \"Example string\";\n"
" pch = (char*) memchr (str, 'p', 16);\n"
"}\n");
TODO_ASSERT_EQUALS("[test.cpp:4]: (error) Buffer access out-of-bounds\n", "", errout.str());
ASSERT_EQUALS("[test.cpp:5]: (error) Buffer access out-of-bounds: str\n", errout.str());
}
// ticket #2121 - buffer access out of bounds when using uint32_t