std.cfg: Added overlappingWriteFunction-check to wcsncat().

This commit is contained in:
orbitcowboy 2021-07-16 14:30:49 +02:00
parent 9b46f59ff0
commit 8096fa4db1
2 changed files with 14 additions and 0 deletions

View File

@ -4982,6 +4982,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<noreturn>false</noreturn>
<returnValue type="wchar_t *"/>
<leak-ignore/>
<not-overlapping-data ptr1-arg="1" ptr2-arg="2" size-arg="3"/>
<arg nr="1" direction="inout">
<not-null/>
<not-uninit/>

View File

@ -106,6 +106,19 @@ char * overlappingWriteFunction_strncat(char *src, char *dest, const std::size_t
return strncat(buffer, buffer + 1, 3);
}
wchar_t * overlappingWriteFunction_wcsncat(wchar_t *src, wchar_t *dest, const std::size_t count)
{
// No warning shall be shown:
(void)wcsncat(dest, src, 42);
(void)wcsncat(dest, src, count);
(void)wcsncat(dest, dest, count);
// cppcheck-suppress overlappingWriteFunction
(void)wcsncat(dest, dest+1, 2);
wchar_t buffer[] = L"strncat";
// cppcheck-suppress overlappingWriteFunction
return wcsncat(buffer, buffer + 1, 3);
}
wchar_t * overlappingWriteFunction_wcscpy(wchar_t *src, wchar_t *dest)
{
// No warning shall be shown: