diff --git a/cfg/std.cfg b/cfg/std.cfg index 685605f1b5a..c024b796b49 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -6371,18 +6371,23 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun std::istream& std::istream::get (char* s, streamsize n, char delim); stream buffer (3) std::istream& std::istream::get (streambuf& sb); std::istream& std::istream::get (streambuf& sb, char delim);--> - - + false - + + + + + + + + 0: + + + + diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 0e6dfedaea7..d27a87d0b47 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -533,6 +534,28 @@ void bufferAccessOutOfBounds_std_ofstream_write(std::ofstream &os, const char* s (void)os.write(s,n); } +// cppcheck-suppress constParameterReference // TODO: FP +void bufferAccessOutOfBounds_std_ifstream_get(std::ifstream& in, std::streambuf& sb) +{ + char cBuf[10]; + // cppcheck-suppress bufferAccessOutOfBounds + in.getline(cBuf, 100); + // cppcheck-suppress bufferAccessOutOfBounds + in.read(cBuf, 100); + // cppcheck-suppress bufferAccessOutOfBounds + in.readsome(cBuf, 100); + // cppcheck-suppress bufferAccessOutOfBounds + in.get(cBuf, 100); + // cppcheck-suppress bufferAccessOutOfBounds + in.get(cBuf, 100, 'a'); + // cppcheck-suppress bufferAccessOutOfBounds + in.getline(cBuf, 100, 'a'); + + in.get(sb, 'a'); + + in.close(); +} + void invalidFunctionArg_fesetexceptflag(const fexcept_t* flagp, int excepts) { (void)std::fesetexceptflag(flagp, excepts);