CheckBufferOverrun::checkStringArgument: sizeof string is strlen+1
This commit is contained in:
parent
9a4bd73a18
commit
254b6438b9
|
@ -1540,7 +1540,7 @@ void CheckBufferOverrun::checkStringArgument()
|
|||
const std::list<Library::ArgumentChecks::MinSize> *minsizes = _settings->library.argminsizes(tok->str(), argnr);
|
||||
if (!minsizes)
|
||||
continue;
|
||||
if (checkMinSizes(*minsizes, tok, Token::getStrLength(argtok), nullptr))
|
||||
if (checkMinSizes(*minsizes, tok, Token::getStrLength(argtok)+1U, nullptr))
|
||||
bufferOverrunError(argtok);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2246,6 +2246,11 @@ private:
|
|||
" memcpy(temp, \"hello world\", 20);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (error) Buffer is accessed out of bounds.\n", errout.str());
|
||||
|
||||
checkstd("void f() {\n"
|
||||
" memcpy(temp, \"abc\", 4);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue