From e90a3053d47243af49e6d06a51e2c69e24c5b286 Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Fri, 16 Jul 2021 14:01:40 +0200 Subject: [PATCH] std.cfg: Added a overlappingWriteFunction-check to strncat --- cfg/std.cfg | 1 + test/cfg/std.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/cfg/std.cfg b/cfg/std.cfg index 0c9500257..7de265506 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -4916,6 +4916,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun false + diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 1d10031a7..26d56f6c9 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -93,6 +93,20 @@ char * overlappingWriteFunction_strcat(char *src, char *dest) 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) { // No warning shall be shown: