astyle formatting
This commit is contained in:
parent
eda18004bd
commit
7d391b37c9
|
@ -932,30 +932,30 @@ void CheckBufferOverrun::checkScope(const Token *tok, const ArrayInfo &arrayInfo
|
||||||
checkFunctionCall(*tok, 2, arrayInfo);
|
checkFunctionCall(*tok, 2, arrayInfo);
|
||||||
|
|
||||||
|
|
||||||
if (_settings->_checkCodingStyle)
|
if (_settings->_checkCodingStyle)
|
||||||
|
{
|
||||||
|
// check for strncpy which is not terminated
|
||||||
|
if (Token::Match(tok, "strncpy ( %varid% , %any% , %num% )", arrayInfo.varid))
|
||||||
{
|
{
|
||||||
// check for strncpy which is not terminated
|
// strncpy takes entire variable length as input size
|
||||||
if (Token::Match(tok, "strncpy ( %varid% , %any% , %num% )", arrayInfo.varid))
|
if ((unsigned int)MathLib::toLongNumber(tok->strAt(6)) >= total_size)
|
||||||
{
|
{
|
||||||
// strncpy takes entire variable length as input size
|
const Token *tok2 = tok->next()->link()->next();
|
||||||
if ((unsigned int)MathLib::toLongNumber(tok->strAt(6)) >= total_size)
|
for (; tok2; tok2 = tok2->next())
|
||||||
{
|
{
|
||||||
const Token *tok2 = tok->next()->link()->next();
|
if (tok2->varId() == tok->tokAt(2)->varId())
|
||||||
for (; tok2; tok2 = tok2->next())
|
|
||||||
{
|
{
|
||||||
if (tok2->varId() == tok->tokAt(2)->varId())
|
if (!Token::Match(tok2, "%varid% [ %any% ] = 0 ;", tok->tokAt(2)->varId()))
|
||||||
{
|
{
|
||||||
if (!Token::Match(tok2, "%varid% [ %any% ] = 0 ;", tok->tokAt(2)->varId()))
|
terminateStrncpyError(tok);
|
||||||
{
|
|
||||||
terminateStrncpyError(tok);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Dangerous usage of strncat..
|
// Dangerous usage of strncat..
|
||||||
if (Token::Match(tok, "strncpy|strncat ( %varid% , %any% , %num% )", arrayInfo.varid))
|
if (Token::Match(tok, "strncpy|strncat ( %varid% , %any% , %num% )", arrayInfo.varid))
|
||||||
|
|
Loading…
Reference in New Issue