std.cfg: Added support for wcsncpy regarding data-overlapping
This commit is contained in:
parent
0d96772304
commit
652e2765bc
|
@ -5238,6 +5238,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
|
||||||
<returnValue type="wchar_t *"/>
|
<returnValue type="wchar_t *"/>
|
||||||
<noreturn>false</noreturn>
|
<noreturn>false</noreturn>
|
||||||
<leak-ignore/>
|
<leak-ignore/>
|
||||||
|
<not-overlapping-data ptr1-arg="1" ptr2-arg="2" size-arg="3"/>
|
||||||
<arg nr="1">
|
<arg nr="1">
|
||||||
<not-null/>
|
<not-null/>
|
||||||
<minsize type="argvalue" arg="3"/>
|
<minsize type="argvalue" arg="3"/>
|
||||||
|
|
|
@ -30,10 +30,22 @@
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
|
|
||||||
char * overlappingWriteFunction_strncpy(char *buf)
|
wchar_t * overlappingWriteFunction_wcsncpy(wchar_t *buf, const std::size_t count)
|
||||||
{
|
{
|
||||||
|
// No warning shall be shown:
|
||||||
|
(void)wcsncpy(&buf[0], &buf[3], count); // size is not known
|
||||||
|
(void)wcsncpy(&buf[0], &buf[3], 3U); // no-overlap
|
||||||
// cppcheck-suppress overlappingWriteFunction
|
// cppcheck-suppress overlappingWriteFunction
|
||||||
return strncpy(&buf[0], &buf[3], 5U);
|
return wcsncpy(&buf[0], &buf[3], 4U);
|
||||||
|
}
|
||||||
|
|
||||||
|
char * overlappingWriteFunction_strncpy(char *buf, const std::size_t count)
|
||||||
|
{
|
||||||
|
// No warning shall be shown:
|
||||||
|
(void)strncpy(&buf[0], &buf[3], count); // size is not known
|
||||||
|
(void)strncpy(&buf[0], &buf[3], 3U); // no-overlap
|
||||||
|
// cppcheck-suppress overlappingWriteFunction
|
||||||
|
return strncpy(&buf[0], &buf[3], 4U);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::bitset<10> std_bitset_test_ignoredReturnValue()
|
std::bitset<10> std_bitset_test_ignoredReturnValue()
|
||||||
|
|
Loading…
Reference in New Issue