diff --git a/lib/checkbufferoverrun.cpp b/lib/checkbufferoverrun.cpp index 90f33853e..e681958dc 100644 --- a/lib/checkbufferoverrun.cpp +++ b/lib/checkbufferoverrun.cpp @@ -477,6 +477,12 @@ void CheckBufferOverrun::checkFunctionCall(const Token &tok, unsigned int par, c total_size["strncpy"] = 3; total_size["memset"] = 3; } + + if (par == 2) + { + total_size["read"] = 3; + total_size["write"] = 3; + } std::map::const_iterator it = total_size.find(tok.str()); if (it != total_size.end()) @@ -1015,19 +1021,6 @@ void CheckBufferOverrun::checkScope(const Token *tok, const ArrayInfo &arrayInfo if (n > total_size) outOfBounds(tok->tokAt(4), "snprintf size"); } - - - // Writing data into array.. - if (Token::Match(tok, "read|write ( %any% , %varid% , %num% )", arrayInfo.varid) && - MathLib::isInt(tok->strAt(6))) - { - const unsigned long len = MathLib::toLongNumber(tok->strAt(6)); - if (len > total_size) - { - bufferOverrun(tok, arrayInfo.varname); - continue; - } - } } }