std.cfg: Improved configuration for wcsrtombs().

This commit is contained in:
orbitcowboy 2022-04-25 18:25:52 +02:00
parent f48d1690a7
commit d1b6954dd8
3 changed files with 21 additions and 1 deletions

View File

@ -5331,7 +5331,9 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<returnValue type="size_t"/> <returnValue type="size_t"/>
<noreturn>false</noreturn> <noreturn>false</noreturn>
<leak-ignore/> <leak-ignore/>
<arg nr="1" direction="out"/> <arg nr="1" direction="out">
<minsize type="argvalue" arg="3"/>
</arg>
<arg nr="2" direction="in"> <arg nr="2" direction="in">
<not-null/> <not-null/>
<not-uninit/> <not-uninit/>

View File

@ -25,6 +25,15 @@
#include <inttypes.h> #include <inttypes.h>
#include <float.h> #include <float.h>
size_t bufferAccessOutOfBounds_wcsrtombs(char * dest, const wchar_t ** src, size_t len, mbstate_t * ps)
{
char buf[42];
(void)wcsrtombs(buf,src,42,ps);
// cppcheck-suppress bufferAccessOutOfBounds
(void)wcsrtombs(buf,src,43,ps);
return wcsrtombs(dest,src,len,ps);
}
void bufferAccessOutOfBounds(void) void bufferAccessOutOfBounds(void)
{ {
char a[5]; char a[5];

View File

@ -31,6 +31,15 @@
#include <iterator> #include <iterator>
#include <vector> #include <vector>
size_t bufferAccessOutOfBounds_wcsrtombs(char * dest, const wchar_t ** src, size_t len, mbstate_t * ps)
{
char buf[42];
(void)std::wcsrtombs(buf,src,42,ps);
// cppcheck-suppress bufferAccessOutOfBounds
(void)std::wcsrtombs(buf,src,43,ps);
return std::wcsrtombs(dest,src,len,ps);
}
void invalidFunctionArg_std_string_substr(const std::string &str, std::size_t pos, std::size_t len) { void invalidFunctionArg_std_string_substr(const std::string &str, std::size_t pos, std::size_t len) {
// cppcheck-suppress invalidFunctionArg // cppcheck-suppress invalidFunctionArg
(void)str.substr(-1,len); (void)str.substr(-1,len);