Running astyle; Improved testing of std::find; std.cfg: Added support for istream::read and ifstream::read.
This commit is contained in:
parent
b5085db3c8
commit
87409ea6b3
13
cfg/std.cfg
13
cfg/std.cfg
|
@ -3989,6 +3989,18 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
|
|||
<not-uninit/>
|
||||
</arg>
|
||||
</function>
|
||||
<!-- istream& read (char* s, streamsize n);
|
||||
ifstream& read (char* s, streamsize n); -->
|
||||
<function name="std::istream::read,std::ifstream::read">
|
||||
<noreturn>false</noreturn>
|
||||
<leak-ignore/>
|
||||
<arg nr="1">
|
||||
<not-null/>
|
||||
</arg>
|
||||
<arg nr="2">
|
||||
<not-uninit/>
|
||||
</arg>
|
||||
</function>
|
||||
<!-- Not part of standard, but widely supported by runtime libraries. -->
|
||||
<!-- char * itoa (int value, char * str, int base); -->
|
||||
<function name="itoa">
|
||||
|
@ -4215,6 +4227,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
|
|||
<podtype name="mbstate_t"/>
|
||||
<podtype name="wint_t"/>
|
||||
<podtype name="jmp_buf"/>
|
||||
<podtype name="std::streamsize,streamsize" sign="s"/>
|
||||
<!-- Fixed width integer sizes, defined in header <stdint.h> -->
|
||||
<define name="INT8_MIN" value="-128"/>
|
||||
<define name="INT16_MIN" value="-32768"/>
|
||||
|
|
|
@ -40,7 +40,7 @@ static const CWE CWE664(664U); // Improper Control of a Resource Through its Li
|
|||
static const CWE CWE685(685U); // Function Call With Incorrect Number of Arguments
|
||||
static const CWE CWE686(686U); // Function Call With Incorrect Argument Type
|
||||
static const CWE CWE687(687U); // Function Call With Incorrectly Specified Argument Value
|
||||
static const CWE CWE704(704U); // Incorrect Type Conversion or Cast
|
||||
static const CWE CWE704(704U); // Incorrect Type Conversion or Cast
|
||||
static const CWE CWE910(910U); // Use of Expired File Descriptor
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
|
|
@ -39,10 +39,10 @@ namespace {
|
|||
}
|
||||
|
||||
// CWE ID used:
|
||||
static const CWE CWE398(398U); // Indicator of Poor Code Quality
|
||||
static const CWE CWE401(401U); // Improper Release of Memory Before Removing Last Reference ('Memory Leak')
|
||||
static const CWE CWE771(771U); // Missing Reference to Active Allocated Resource
|
||||
static const CWE CWE772(772U); // Missing Release of Resource after Effective Lifetime
|
||||
static const CWE CWE398(398U); // Indicator of Poor Code Quality
|
||||
static const CWE CWE401(401U); // Improper Release of Memory Before Removing Last Reference ('Memory Leak')
|
||||
static const CWE CWE771(771U); // Missing Reference to Active Allocated Resource
|
||||
static const CWE CWE772(772U); // Missing Release of Resource after Effective Lifetime
|
||||
|
||||
/**
|
||||
* Count function parameters
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace {
|
|||
CheckNullPointer instance;
|
||||
}
|
||||
|
||||
static const CWE CWE476(476U); // NULL Pointer Dereference
|
||||
static const CWE CWE476(476U); // NULL Pointer Dereference
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ namespace {
|
|||
static const struct CWE CWE128(128U); // Wrap-around Error
|
||||
static const struct CWE CWE131(131U); // Incorrect Calculation of Buffer Size
|
||||
static const struct CWE CWE197(197U); // Numeric Truncation Error
|
||||
static const struct CWE CWE362(362U); // Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
|
||||
static const struct CWE CWE369(369U); // Divide By Zero
|
||||
static const struct CWE CWE362(362U); // Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')
|
||||
static const struct CWE CWE369(369U); // Divide By Zero
|
||||
static const struct CWE CWE398(398U); // Indicator of Poor Code Quality
|
||||
static const struct CWE CWE475(475U); // Undefined Behavior for Input to API
|
||||
static const struct CWE CWE482(482U); // Comparing instead of Assigning
|
||||
|
@ -50,7 +50,7 @@ static const struct CWE CWE687(687U); // Function Call With Incorrectly Specif
|
|||
static const struct CWE CWE688(688U); // Function Call With Incorrect Variable or Reference as Argument
|
||||
static const struct CWE CWE704(704U); // Incorrect Type Conversion or Cast
|
||||
static const struct CWE CWE758(758U); // Reliance on Undefined, Unspecified, or Implementation-Defined Behavior
|
||||
static const struct CWE CWE768(768U); // Incorrect Short Circuit Evaluation
|
||||
static const struct CWE CWE768(768U); // Incorrect Short Circuit Evaluation
|
||||
static const struct CWE CWE783(783U); // Operator Precedence Logic Error
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
|
|
@ -1254,7 +1254,7 @@ void CheckStl::autoPointerError(const Token *tok)
|
|||
reportError(tok, Severity::style, "useAutoPointerCopy",
|
||||
"Copying 'auto_ptr' pointer to another does not create two equal objects since one has lost its ownership of the pointer.\n"
|
||||
"'std::auto_ptr' has semantics of strict ownership, meaning that the 'auto_ptr' instance is the sole entity responsible for the object's lifetime. If an 'auto_ptr' is copied, the source looses the reference.",
|
||||
CWE398, false);
|
||||
CWE398, false);
|
||||
}
|
||||
|
||||
void CheckStl::autoPointerContainerError(const Token *tok)
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <cinttypes>
|
||||
#include <istream>
|
||||
#include <fstream>
|
||||
|
||||
void bufferAccessOutOfBounds(void)
|
||||
{
|
||||
|
@ -2984,17 +2986,42 @@ void uninitvar_find(std::string s)
|
|||
(void)s.find(pc,0);
|
||||
// cppcheck-suppress uninitvar
|
||||
(void)s.find(pc,pos);
|
||||
// cppcheck-suppress uninitvar
|
||||
(void)s.find("test",pos);
|
||||
|
||||
// testing of size_t find (char c, size_t pos = 0) const;
|
||||
char c;
|
||||
// cppcheck-suppress uninitvar
|
||||
(void)s.find(c,pos);
|
||||
/*
|
||||
// testing of size_t find (const char* pc, size_t pos, size_t n) const;
|
||||
size_t n;
|
||||
// cppcheck-suppress uninitvar
|
||||
(void)s.find(pc,pos,n); // #6991
|
||||
*/
|
||||
|
||||
// testing of size_t find (const char* pc, size_t pos, size_t n) const;
|
||||
size_t n;
|
||||
// cppcheck-suppress uninitvar
|
||||
(void)s.find(pc,pos,n); // #6991
|
||||
// cppcheck-suppress uninitvar
|
||||
(void)s.find("test",pos,n);
|
||||
// cppcheck-suppress uninitvar
|
||||
(void)s.find("test",1,n);
|
||||
// cppcheck-suppress uninitvar
|
||||
(void)s.find("test",pos,1);
|
||||
// cppcheck-suppress uninitvar
|
||||
(void)s.find(pc,1,1);
|
||||
}
|
||||
|
||||
void uninivar_ifstream_read(std::ifstream &f)
|
||||
{
|
||||
int size;
|
||||
char buffer[10];
|
||||
// cppcheck-suppress uninitvar
|
||||
f.read(buffer, size);
|
||||
}
|
||||
|
||||
void uninivar_istream_read(std::istream &f)
|
||||
{
|
||||
int size;
|
||||
char buffer[10];
|
||||
// cppcheck-suppress uninitvar
|
||||
f.read(buffer, size);
|
||||
}
|
||||
|
||||
void invalidFunctionArgBool_abs(bool b, double x, double y)
|
||||
|
@ -3015,6 +3042,18 @@ void ignoredReturnValue_abs(int i)
|
|||
std::abs(-199);
|
||||
}
|
||||
|
||||
void nullPointer_ifstream_read(std::ifstream &f)
|
||||
{
|
||||
// cppcheck-suppress nullPointer
|
||||
f.read(NULL, 10);
|
||||
}
|
||||
|
||||
void nullPointer_istream_read(std::istream &f)
|
||||
{
|
||||
// cppcheck-suppress nullPointer
|
||||
f.read(NULL, 10);
|
||||
}
|
||||
|
||||
void nullPointer_asctime(void)
|
||||
{
|
||||
struct tm *tm = 0;
|
||||
|
|
Loading…
Reference in New Issue