buffer overruns : renamed functions + minor simplification
This commit is contained in:
parent
6b06df766b
commit
7301709699
|
@ -520,7 +520,7 @@ void CheckBufferOverrunClass::CheckBufferOverrun_StructVariable()
|
|||
|
||||
|
||||
|
||||
void CheckBufferOverrunClass::CheckBufferOverrun()
|
||||
void CheckBufferOverrunClass::bufferOverrun()
|
||||
{
|
||||
CheckBufferOverrun_LocalVariable();
|
||||
CheckBufferOverrun_StructVariable();
|
||||
|
@ -538,21 +538,14 @@ void CheckBufferOverrunClass::CheckBufferOverrun()
|
|||
// Dangerous functions
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void CheckBufferOverrunClass::WarningDangerousFunctions()
|
||||
void CheckBufferOverrunClass::dangerousFunctions()
|
||||
{
|
||||
for (const TOKEN *tok = _tokenizer->tokens(); tok; tok = tok->next())
|
||||
{
|
||||
if (TOKEN::Match(tok, "gets ("))
|
||||
if (TOKEN::Match(tok, "gets|scanf ("))
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << _tokenizer->fileLine(tok) << ": Found 'gets'. You should use 'fgets' instead";
|
||||
_errorLogger->reportErr(ostr.str());
|
||||
}
|
||||
|
||||
else if (TOKEN::Match(tok, "scanf (") && strcmp(tok->strAt(2),"\"%s\"") == 0)
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << _tokenizer->fileLine(tok) << ": Found 'scanf'. You should use 'fgets' instead";
|
||||
ostr << _tokenizer->fileLine(tok) << ": Found '" << tok->str() << "'. You should use 'fgets' instead";
|
||||
_errorLogger->reportErr(ostr.str());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,11 +32,11 @@ public:
|
|||
~CheckBufferOverrunClass();
|
||||
|
||||
// Buffer overrun..
|
||||
void CheckBufferOverrun();
|
||||
void bufferOverrun();
|
||||
|
||||
|
||||
// Dangerous functions that can cause buffer overruns
|
||||
void WarningDangerousFunctions();
|
||||
void dangerousFunctions();
|
||||
private:
|
||||
void CheckBufferOverrun_StructVariable();
|
||||
void CheckBufferOverrun_LocalVariable();
|
||||
|
|
|
@ -246,7 +246,7 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
|
|||
|
||||
// Buffer overruns..
|
||||
CheckBufferOverrunClass checkBufferOverrun( &_tokenizer, _settings, this );
|
||||
checkBufferOverrun.CheckBufferOverrun();
|
||||
checkBufferOverrun.bufferOverrun();
|
||||
|
||||
// Check that all class constructors are ok.
|
||||
checkClass.constructors();
|
||||
|
@ -271,7 +271,7 @@ void CppCheck::checkFile(const std::string &code, const char FileName[])
|
|||
|
||||
|
||||
// Dangerous functions, such as 'gets' and 'scanf'
|
||||
checkBufferOverrun.WarningDangerousFunctions();
|
||||
checkBufferOverrun.dangerousFunctions();
|
||||
|
||||
|
||||
// Invalid function usage..
|
||||
|
|
|
@ -57,7 +57,7 @@ private:
|
|||
Settings settings;
|
||||
settings._showAll = true;
|
||||
CheckBufferOverrunClass checkBufferOverrun( &tokenizer, settings, this );
|
||||
checkBufferOverrun.CheckBufferOverrun();
|
||||
checkBufferOverrun.bufferOverrun();
|
||||
}
|
||||
|
||||
void run()
|
||||
|
|
Loading…
Reference in New Issue