std.cfg: Added a overlappingWriteFunction-check to strncat

This commit is contained in:
orbitcowboy 2021-07-16 14:01:40 +02:00
parent cbb07b6247
commit e90a3053d4
2 changed files with 15 additions and 0 deletions

View File

@ -4916,6 +4916,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<returnValue type="char *"/> <returnValue type="char *"/>
<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" direction="inout"> <arg nr="1" direction="inout">
<not-null/> <not-null/>
<not-uninit/> <not-uninit/>

View File

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