std.cfg: Improved configuration of std::ofstream::write(), std::ostringstream::write(), std::ostream::write() and std::fstream().

This commit is contained in:
orbitcowboy 2022-05-10 09:30:13 +02:00
parent 54f832a2fe
commit 440e8f9c22
2 changed files with 45 additions and 0 deletions

View File

@ -6411,6 +6411,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<arg nr="1" direction="in"> <arg nr="1" direction="in">
<not-uninit/> <not-uninit/>
<not-null/> <not-null/>
<minsize type="argvalue" arg="2"/>
</arg> </arg>
<arg nr="2" direction="in"> <arg nr="2" direction="in">
<not-uninit/> <not-uninit/>
@ -6425,6 +6426,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<arg nr="1" direction="in"> <arg nr="1" direction="in">
<not-uninit/> <not-uninit/>
<not-null/> <not-null/>
<minsize type="argvalue" arg="2"/>
</arg> </arg>
<arg nr="2" direction="in"> <arg nr="2" direction="in">
<not-uninit/> <not-uninit/>
@ -6439,6 +6441,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<arg nr="1" direction="in"> <arg nr="1" direction="in">
<not-uninit/> <not-uninit/>
<not-null/> <not-null/>
<minsize type="argvalue" arg="2"/>
</arg> </arg>
<arg nr="2" direction="in"> <arg nr="2" direction="in">
<not-uninit/> <not-uninit/>
@ -6453,6 +6456,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<arg nr="1" direction="in"> <arg nr="1" direction="in">
<not-uninit/> <not-uninit/>
<not-null/> <not-null/>
<minsize type="argvalue" arg="2"/>
</arg> </arg>
<arg nr="2" direction="in"> <arg nr="2" direction="in">
<not-uninit/> <not-uninit/>

View File

@ -27,12 +27,53 @@
#include <fstream> #include <fstream>
#include <functional> #include <functional>
#include <iomanip> #include <iomanip>
#include <ios>
#include <iostream> #include <iostream>
#include <istream> #include <istream>
#include <iterator> #include <iterator>
#include <vector> #include <vector>
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 invalidFunctionArg_fesetexceptflag(fexcept_t* flagp, int excepts)
{ {
(void)std::fesetexceptflag(flagp, excepts); (void)std::fesetexceptflag(flagp, excepts);