| 870 | } |
| 871 | |
| 872 | void CheckBufferOverrunImpl::argumentSizeError(const Token *tok, const std::string &functionName, nonneg int paramIndex, const std::string ¶mExpression, const Variable *paramVar, const Variable *functionArg) |
| 873 | { |
| 874 | const std::string strParamNum = std::to_string(paramIndex + 1) + getOrdinalText(paramIndex + 1); |
| 875 | ErrorPath errorPath; |
| 876 | errorPath.emplace_back(tok, "Function '" + functionName + "' is called"); |
| 877 | if (functionArg) |
| 878 | errorPath.emplace_back(functionArg->nameToken(), "Declaration of " + strParamNum + " function argument."); |
| 879 | if (paramVar) |
| 880 | errorPath.emplace_back(paramVar->nameToken(), "Passing buffer '" + paramVar->name() + "' to function that is declared here"); |
| 881 | errorPath.emplace_back(tok, ""); |
| 882 | |
| 883 | reportError(std::move(errorPath), Severity::warning, "argumentSize", |
| 884 | "$symbol:" + functionName + '\n' + |
| 885 | "Buffer '" + paramExpression + "' is too small, the function '" + functionName + "' expects a bigger buffer in " + strParamNum + " argument", CWE_ARGUMENT_SIZE, Certainty::normal); |
| 886 | } |
| 887 | |
| 888 | //--------------------------------------------------------------------------- |
| 889 | // CTU.. |
no test coverage detected