CheckBufferOverrun: the bufferNotZeroTerminated did not work well, hide that for now

This commit is contained in:
Daniel Marjamäki 2019-03-13 06:45:01 +01:00
parent 81a1d744c6
commit 2ecfae0a98
1 changed files with 2 additions and 5 deletions

View File

@ -474,7 +474,7 @@ void CheckBufferOverrun::stringNotZeroTerminated()
const SymbolDatabase *symbolDatabase = mTokenizer->getSymbolDatabase();
for (const Scope * const scope : symbolDatabase->functionScopes) {
for (const Token *tok = scope->bodyStart; tok && tok != scope->bodyEnd; tok = tok->next()) {
if (!Token::Match(tok, "strncpy|memcpy ("))
if (!Token::simpleMatch(tok, "strncpy ("))
continue;
const std::vector<const Token *> args = getArguments(tok);
if (args.size() != 3)
@ -502,10 +502,7 @@ void CheckBufferOverrun::stringNotZeroTerminated()
if (isZeroTerminated)
continue;
// TODO: Locate unsafe string usage..
if (tok->str() == "strncpy")
terminateStrncpyError(tok, args[0]->expressionString());
else
bufferNotZeroTerminatedError(tok, args[0]->expressionString(), tok->str());
terminateStrncpyError(tok, args[0]->expressionString());
}
}
}