From 04f24b4220968046902d43b4db998b2523da234b Mon Sep 17 00:00:00 2001 From: Roberto Martelloni Date: Sat, 24 Dec 2016 23:07:37 +0000 Subject: [PATCH] CWE mapping of accessMoved, accessForwarded, nullPointerArithmeticRedundantCheck, nullPointerArithmetic --- lib/checknullpointer.cpp | 3 ++- lib/checkother.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/checknullpointer.cpp b/lib/checknullpointer.cpp index 4fe2c9909..dad59d08f 100644 --- a/lib/checknullpointer.cpp +++ b/lib/checknullpointer.cpp @@ -31,6 +31,7 @@ namespace { } static const CWE CWE476(476U); // NULL Pointer Dereference +static const CWE CWE682(682U); // Incorrect Calculation //--------------------------------------------------------------------------- @@ -538,7 +539,7 @@ void CheckNullPointer::arithmeticError(const Token *tok, const ValueFlow::Value (value && value->condition) ? Severity::warning : Severity::error, (value && value->condition) ? "nullPointerArithmeticRedundantCheck" : "nullPointerArithmetic", errmsg, - CWE(0), // unknown - pointer overflow + CWE682, // unknown - pointer overflow value && value->inconclusive); } diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 8b9aa9d18..849b03566 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -45,6 +45,7 @@ static const struct CWE CWE561(561U); // Dead Code static const struct CWE CWE563(563U); // Assignment to Variable without Use ('Unused Variable') static const struct CWE CWE570(570U); // Expression is Always False static const struct CWE CWE571(571U); // Expression is Always True +static const struct CWE CWE672(672U); // Operation on a Resource after Expiration or Release static const struct CWE CWE686(686U); // Function Call With Incorrect Argument Type static const struct CWE CWE687(687U); // Function Call With Incorrectly Specified Argument Value static const struct CWE CWE688(688U); // Function Call With Incorrect Variable or Reference as Argument @@ -2768,6 +2769,6 @@ void CheckOther::accessMovedError(const Token *tok, const std::string &varname, return; } const std::string errmsg(std::string("Access of ") + kindString + " variable " + varname + "."); - reportError(tok, Severity::warning, errorId, errmsg, CWE(0U), inconclusive); + reportError(tok, Severity::warning, errorId, errmsg, CWE672, inconclusive); }