Added more overlapping data configurations

This commit is contained in:
orbitcowboy 2021-07-10 18:41:36 +02:00
parent 7ad64891ea
commit 10fb1851c5
2 changed files with 32 additions and 0 deletions

View File

@ -4717,6 +4717,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
<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" direction="out"> <arg nr="1" direction="out">
<not-null/> <not-null/>
<minsize type="argvalue" arg="3"/> <minsize type="argvalue" arg="3"/>
@ -4737,6 +4738,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
<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="out"> <arg nr="1" direction="out">
<not-null/> <not-null/>
<minsize type="argvalue" arg="3"/> <minsize type="argvalue" arg="3"/>
@ -4757,6 +4759,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
<leak-ignore/> <leak-ignore/>
<returnValue type="void *"/> <returnValue type="void *"/>
<noreturn>false</noreturn> <noreturn>false</noreturn>
<not-overlapping-data ptr1-arg="1" ptr2-arg="2" size-arg="4"/>
<arg nr="1" direction="out"> <arg nr="1" direction="out">
<not-null/> <not-null/>
<minsize type="sizeof" arg="2"/> <minsize type="sizeof" arg="2"/>

View File

@ -26,6 +26,35 @@
#include <stdarg.h> #include <stdarg.h>
#include <ctype.h> #include <ctype.h>
#include <stdbool.h> #include <stdbool.h>
#include <wchar.h>
#include <string.h>
void overlappingWriteFunction_memccpy(unsigned char *src, unsigned char *dest, int c, size_t count)
{
// No warning shall be shown:
(void)memccpy(dest, src, c, count);
(void)memccpy(dest, src, 42, count);
// cppcheck-suppress overlappingWriteFunction
(void)memccpy(dest, dest, c, 4);
// cppcheck-suppress overlappingWriteFunction
(void)memccpy(dest, dest+3, c, 4);
}
void overlappingWriteFunction_stpncpy(char *src, char *dest, ssize_t n)
{
// No warning shall be shown:
(void) stpncpy(dest, src, n);
// cppcheck-suppress overlappingWriteFunction
(void)stpncpy(src, src+3, 4);
}
wchar_t* overlappingWriteFunction_wcpncpy(wchar_t *src, wchar_t *dest, ssize_t n)
{
// No warning shall be shown:
(void) wcpncpy(dest, src, n);
// cppcheck-suppress overlappingWriteFunction
return wcpncpy(src, src+3, 4);
}
void overlappingWriteFunction_swab(char *src, char *dest, ssize_t n) void overlappingWriteFunction_swab(char *src, char *dest, ssize_t n)
{ {