CheckBufferOverrun::checkScope(): use Token::getStrLength().
No functional change.
This commit is contained in:
parent
843ede94f3
commit
1a982a2a19
|
@ -348,16 +348,8 @@ void CheckBufferOverrun::checkScope(const Token *tok, const char *varname[], con
|
||||||
// Writing data into array..
|
// Writing data into array..
|
||||||
if (Token::Match(tok, ("strcpy|strcat ( " + varnames + " , %str% )").c_str()))
|
if (Token::Match(tok, ("strcpy|strcat ( " + varnames + " , %str% )").c_str()))
|
||||||
{
|
{
|
||||||
int len = 0;
|
size_t len = Token::getStrLength(tok->tokAt(varc + 4));
|
||||||
const char *str = tok->strAt(varc + 4);
|
if (len >= static_cast<size_t>(size))
|
||||||
while (*str)
|
|
||||||
{
|
|
||||||
if (*str == '\\')
|
|
||||||
++str;
|
|
||||||
++str;
|
|
||||||
++len;
|
|
||||||
}
|
|
||||||
if (len > 2 && len >= (int)size + 2)
|
|
||||||
{
|
{
|
||||||
bufferOverrun(tok);
|
bufferOverrun(tok);
|
||||||
}
|
}
|
||||||
|
@ -420,15 +412,7 @@ void CheckBufferOverrun::checkScope(const Token *tok, const char *varname[], con
|
||||||
{
|
{
|
||||||
if (tok2->str()[0] == '\"')
|
if (tok2->str()[0] == '\"')
|
||||||
{
|
{
|
||||||
len -= 2;
|
len += Token::getStrLength(tok2);
|
||||||
const char *str = tok2->str().c_str();
|
|
||||||
while (*str)
|
|
||||||
{
|
|
||||||
if (*str == '\\')
|
|
||||||
++str;
|
|
||||||
++str;
|
|
||||||
++len;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (len >= (int)size)
|
if (len >= (int)size)
|
||||||
|
|
Loading…
Reference in New Issue