Skip to content

Commit d1b6954

Browse files
committed
std.cfg: Improved configuration for wcsrtombs().
1 parent f48d169 commit d1b6954

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

cfg/std.cfg

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5331,7 +5331,9 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
53315331
<returnValue type="size_t"/>
53325332
<noreturn>false</noreturn>
53335333
<leak-ignore/>
5334-
<arg nr="1" direction="out"/>
5334+
<arg nr="1" direction="out">
5335+
<minsize type="argvalue" arg="3"/>
5336+
</arg>
53355337
<arg nr="2" direction="in">
53365338
<not-null/>
53375339
<not-uninit/>

test/cfg/std.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@
2525
#include <inttypes.h>
2626
#include <float.h>
2727

28+
size_t bufferAccessOutOfBounds_wcsrtombs(char * dest, const wchar_t ** src, size_t len, mbstate_t * ps)
29+
{
30+
char buf[42];
31+
(void)wcsrtombs(buf,src,42,ps);
32+
// cppcheck-suppress bufferAccessOutOfBounds
33+
(void)wcsrtombs(buf,src,43,ps);
34+
return wcsrtombs(dest,src,len,ps);
35+
}
36+
2837
void bufferAccessOutOfBounds(void)
2938
{
3039
char a[5];

test/cfg/std.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@
3131
#include <iterator>
3232
#include <vector>
3333

34+
size_t bufferAccessOutOfBounds_wcsrtombs(char * dest, const wchar_t ** src, size_t len, mbstate_t * ps)
35+
{
36+
char buf[42];
37+
(void)std::wcsrtombs(buf,src,42,ps);
38+
// cppcheck-suppress bufferAccessOutOfBounds
39+
(void)std::wcsrtombs(buf,src,43,ps);
40+
return std::wcsrtombs(dest,src,len,ps);
41+
}
42+
3443
void invalidFunctionArg_std_string_substr(const std::string &str, std::size_t pos, std::size_t len) {
3544
// cppcheck-suppress invalidFunctionArg
3645
(void)str.substr(-1,len);

0 commit comments

Comments
 (0)