Skip to content

Commit 12ac67f

Browse files
committed
Fix more functions
1 parent 1367f16 commit 12ac67f

4 files changed

Lines changed: 35 additions & 7 deletions

File tree

‎cfg/gnu.cfg‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@
650650
<not-bool/>
651651
</arg>
652652
</function>
653-
<!-- https://man7.org/linux/man-pages/man3/mempcpy.3.html-->
653+
<!-- https://man7.org/linux/man-pages/man3/wmempcpy.3.html -->
654654
<!-- wchar_t *wmempcpy(wchar_t *restrict dest, const wchar_t *restrict src, size_t n);-->
655655
<function name="wmempcpy">
656656
<returnValue type="wchar_t *"/>
@@ -659,12 +659,12 @@
659659
<not-overlapping-data ptr1-arg="1" ptr2-arg="2" size-arg="3"/>
660660
<arg nr="1" direction="out">
661661
<not-null/>
662-
<minsize type="argvalue" arg="3"/>
662+
<minsize type="argvalue" arg="3" baseType="wchar_t"/>
663663
</arg>
664664
<arg nr="2" direction="in">
665665
<not-null/>
666666
<not-uninit/>
667-
<minsize type="argvalue" arg="3"/>
667+
<minsize type="argvalue" arg="3" baseType="wchar_t"/>
668668
</arg>
669669
<arg nr="3" direction="in">
670670
<not-uninit/>

‎cfg/std.cfg‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3928,7 +3928,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
39283928
<arg nr="1">
39293929
<not-null/>
39303930
<not-uninit/>
3931-
<minsize type="argvalue" arg="3"/>
3931+
<minsize type="argvalue" arg="3" baseType="wchar_t"/>
39323932
</arg>
39333933
<arg nr="2" direction="in">
39343934
<not-uninit/>
@@ -4081,13 +4081,13 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
40814081
<leak-ignore/>
40824082
<arg nr="1" direction="out">
40834083
<not-null/>
4084-
<minsize type="argvalue" arg="3"/>
4084+
<minsize type="argvalue" arg="3" baseType="wchar_t"/>
40854085
</arg>
40864086
<arg nr="2">
40874087
<!-- TODO: direction? memory could be overwritten -->
40884088
<not-null/>
40894089
<not-uninit/>
4090-
<minsize type="argvalue" arg="3"/>
4090+
<minsize type="argvalue" arg="3" baseType="wchar_t"/>
40914091
</arg>
40924092
<arg nr="3" direction="in">
40934093
<not-uninit/>
@@ -4141,7 +4141,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
41414141
<leak-ignore/>
41424142
<arg nr="1" direction="out">
41434143
<not-null/>
4144-
<minsize type="argvalue" arg="3"/>
4144+
<minsize type="argvalue" arg="3" baseType="wchar_t"/>
41454145
</arg>
41464146
<arg nr="2" direction="in">
41474147
<not-uninit/>

‎test/cfg/gnu.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,13 @@ wchar_t *nullPointer_wmempcpy(wchar_t *dest, const wchar_t *src, size_t n)
376376
return wmempcpy(dest,src,n);
377377
}
378378

379+
void bufferAccessOutOfBounds_wmempcpy(const wchar_t *src)
380+
{
381+
wchar_t buf[3];
382+
// cppcheck-suppress bufferAccessOutOfBounds
383+
wmempcpy(buf, src, 5);
384+
}
385+
379386
int uninitvar_getpw(uid_t uid, char *buf)
380387
{
381388
uid_t someUid;

‎test/cfg/std.c‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2951,6 +2951,27 @@ void *bufferAccessOutOfBounds_memchr(const void *s, int c, size_t n)
29512951
return memchr(s,c,n);
29522952
}
29532953

2954+
bool bufferAccessOutOfBounds_wmemchr(wchar_t c)
2955+
{
2956+
const wchar_t buf[] = {'a', 'b', 'c'};
2957+
// cppcheck-suppress bufferAccessOutOfBounds
2958+
return wmemchr(buf, c, 5) != NULL;
2959+
}
2960+
2961+
void bufferAccessOutOfBounds_wmemset(wchar_t c)
2962+
{
2963+
wchar_t buf[3];
2964+
// cppcheck-suppress bufferAccessOutOfBounds
2965+
wmemset(buf, c, 5);
2966+
}
2967+
2968+
void bufferAccessOutOfBounds_wmemmove(const wchar_t* s)
2969+
{
2970+
wchar_t d[3];
2971+
// cppcheck-suppress bufferAccessOutOfBounds
2972+
wmemmove(d, s, 5);
2973+
}
2974+
29542975
void uninitvar_wmemchr(void)
29552976
{
29562977
const wchar_t *cs;

0 commit comments

Comments
 (0)