diff --git a/cfg/std.cfg b/cfg/std.cfg index 78ff19f63..44ca631d8 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -6411,6 +6411,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun + @@ -6425,6 +6426,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun + @@ -6439,6 +6441,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun + @@ -6453,6 +6456,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun + diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 57a3fc15c..a73e98358 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -27,12 +27,53 @@ #include #include #include +#include #include #include #include #include +void bufferAccessOutOfBounds_std_fstream_write(std::fstream &fs, const char* s, std::streamsize n) +{ + char buf[42] = {0}; + (void)fs.write(buf,42); + // cppcheck-suppress bufferAccessOutOfBounds + (void)fs.write(buf,43); + (void)fs.write(buf,n); + (void)fs.write(s,n); +} + +void bufferAccessOutOfBounds_std_ostream_write(std::ostream &os, const char* s, std::streamsize n) +{ + char buf[42] = {0}; + (void)os.write(buf,42); + // cppcheck-suppress bufferAccessOutOfBounds + (void)os.write(buf,43); + (void)os.write(buf,n); + (void)os.write(s,n); +} + +void bufferAccessOutOfBounds_std_ostringstream_write(std::ostringstream &oss, const char* s, std::streamsize n) +{ + char buf[42] = {0}; + (void)oss.write(buf,42); + // cppcheck-suppress bufferAccessOutOfBounds + (void)oss.write(buf,43); + (void)oss.write(buf,n); + (void)oss.write(s,n); +} + +void bufferAccessOutOfBounds_std_ofstream_write(std::ofstream &os, const char* s, std::streamsize n) +{ + char buf[42] = {0}; + (void)os.write(buf,42); + // cppcheck-suppress bufferAccessOutOfBounds + (void)os.write(buf,43); + (void)os.write(buf,n); + (void)os.write(s,n); +} + void invalidFunctionArg_fesetexceptflag(fexcept_t* flagp, int excepts) { (void)std::fesetexceptflag(flagp, excepts);