From 10fb1851c50b11c0af6126ce255ac40e5d6b40ba Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Sat, 10 Jul 2021 18:41:36 +0200 Subject: [PATCH] Added more overlapping data configurations --- cfg/posix.cfg | 3 +++ test/cfg/posix.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/cfg/posix.cfg b/cfg/posix.cfg index f4f8720cc..053092eb3 100644 --- a/cfg/posix.cfg +++ b/cfg/posix.cfg @@ -4717,6 +4717,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s false + @@ -4737,6 +4738,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s false + @@ -4757,6 +4759,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s false + diff --git a/test/cfg/posix.c b/test/cfg/posix.c index affa721a1..e9740a6bc 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -26,6 +26,35 @@ #include #include #include +#include +#include + +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) {