Cppcheck
|
#include "checkbufferoverrun.h"
#include "astutils.h"
#include "errorlogger.h"
#include "library.h"
#include "mathlib.h"
#include "platform.h"
#include "settings.h"
#include "symboldatabase.h"
#include "token.h"
#include "tokenize.h"
#include "utils.h"
#include "valueflow.h"
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <iterator>
#include <numeric>
#include <sstream>
#include <utility>
#include "xml.h"
Go to the source code of this file.
Functions | |
static const ValueFlow::Value * | getBufferSizeValue (const Token *tok) |
static int | getMinFormatStringOutputLength (const std::vector< const Token * > ¶meters, nonneg int formatStringArgNr) |
static bool | getDimensionsEtc (const Token *const arrayToken, const Settings &settings, std::vector< Dimension > &dimensions, ErrorPath &errorPath, bool &mightBeLarger, MathLib::bigint &path) |
static ValueFlow::Value | makeSizeValue (MathLib::bigint size, MathLib::bigint path) |
static std::vector< ValueFlow::Value > | getOverrunIndexValues (const Token *tok, const Token *arrayToken, const std::vector< Dimension > &dimensions, const std::vector< const Token * > &indexTokens, MathLib::bigint path) |
static std::string | stringifyIndexes (const std::string &array, const std::vector< ValueFlow::Value > &indexValues) |
static std::string | arrayIndexMessage (const Token *tok, const std::vector< Dimension > &dimensions, const std::vector< ValueFlow::Value > &indexValues, const Token *condition) |
static bool | checkBufferSize (const Token *ftok, const Library::ArgumentChecks::MinSize &minsize, const std::vector< const Token * > &args, const MathLib::bigint bufferSize, const Settings &settings, const Tokenizer *tokenizer) |
static bool | isVLAIndex (const Token *tok) |
Variables | |
static const CWE | CWE131 (131U) |
static const CWE | CWE170 (170U) |
static const CWE | CWE_ARGUMENT_SIZE (398U) |
static const CWE | CWE_ARRAY_INDEX_THEN_CHECK (398U) |
static const CWE | CWE758 (758U) |
static const CWE | CWE_POINTER_ARITHMETIC_OVERFLOW (758U) |
static const CWE | CWE_BUFFER_UNDERRUN (786U) |
static const CWE | CWE_BUFFER_OVERRUN (788U) |
|
static |
Definition at line 384 of file checkbufferoverrun.cpp.
References Token::astOperand1(), ValueFlow::eitherTheConditionIsRedundant(), and stringifyIndexes().
Referenced by CheckBufferOverrun::arrayIndexError(), and CheckBufferOverrun::negativeIndexError().
|
static |
Definition at line 587 of file checkbufferoverrun.cpp.
References Library::ArgumentChecks::MinSize::arg, Library::ArgumentChecks::MinSize::arg2, Library::ArgumentChecks::MinSize::ARGVALUE, Library::ArgumentChecks::MinSize::baseType, Token::getKnownIntValue(), getMinFormatStringOutputLength(), Token::getStrLength(), Token::getValueTokenMaxStrLength(), Token::hasKnownIntValue(), Library::isargformatstr(), Settings::library, Library::ArgumentChecks::MinSize::MUL, Library::ArgumentChecks::MinSize::NONE, Library::ArgumentChecks::MinSize::SIZEOF, Tokenizer::sizeOfType(), Library::ArgumentChecks::MinSize::STRLEN, Library::ArgumentChecks::MinSize::type, Library::ArgumentChecks::MinSize::VALUE, and Library::ArgumentChecks::MinSize::value.
|
static |
Definition at line 68 of file checkbufferoverrun.cpp.
References ValueFlow::Value::isBufferSizeValue(), and Token::values().
Referenced by CheckBufferOverrun::getBufferSize(), and getDimensionsEtc().
|
static |
Definition at line 190 of file checkbufferoverrun.cpp.
References Token::astOperand2(), ValueFlow::Value::errorPath, getBufferSizeValue(), Token::getStrArraySize(), Token::getValueTokenMinStrSize(), Token::hasKnownValue(), ValueFlow::Value::intvalue, ValueType::isFloat(), ValueType::isIntegral(), ValueFlow::Value::isKnown(), Dimension::known, Token::Match(), Dimension::num, op1_and_op2, Token::originalName(), ValueFlow::Value::path, Settings::platform, ValueType::pointer, Dimension::tok, ValueType::typeSize(), Token::valueType(), Token::variable(), and visitAstNodes().
Referenced by CheckBufferOverrun::arrayIndex(), and CheckBufferOverrun::pointerArithmetic().
|
static |
Definition at line 75 of file checkbufferoverrun.cpp.
References Token::eString, and Token::getStrLength().
Referenced by checkBufferSize().
|
static |
Definition at line 239 of file checkbufferoverrun.cpp.
References Token::astOperand2(), Token::astParent(), ValueFlow::isOutOfBounds(), Token::isUnaryOp(), makeSizeValue(), Token::Match(), Token::simpleMatch(), Token::str(), ValueFlow::Value::unknown(), and Token::variable().
Referenced by CheckBufferOverrun::arrayIndex(), and CheckBufferOverrun::pointerArithmetic().
|
static |
Definition at line 1148 of file checkbufferoverrun.cpp.
References Token::astOperand1(), Token::astOperand2(), Token::str(), and Token::varId().
Referenced by CheckBufferOverrun::negativeArraySize().
|
static |
Definition at line 232 of file checkbufferoverrun.cpp.
References ValueFlow::Value::path.
Referenced by getOverrunIndexValues(), and CheckBufferOverrun::objectIndex().
|
static |
Definition at line 366 of file checkbufferoverrun.cpp.
Referenced by arrayIndexMessage().
|
static |
Referenced by CheckBufferOverrun::negativeMemoryAllocationSizeError().
|
static |
Referenced by CheckBufferOverrun::terminateStrncpyError().
|
static |
Referenced by CheckBufferOverrun::negativeArraySizeError(), and CheckBufferOverrun::objectIndexError().
|
static |
Referenced by CheckBufferOverrun::argumentSizeError().
|
static |
Referenced by CheckBufferOverrun::arrayIndexThenCheckError().
|
static |
|
static |
Referenced by CheckBufferOverrun::analyseWholeProgram1(), and CheckBufferOverrun::negativeIndexError().
|
static |