From 8096fa4db195998168cf9bb20eeea05ae256fb7d Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Fri, 16 Jul 2021 14:30:49 +0200 Subject: [PATCH] std.cfg: Added overlappingWriteFunction-check to wcsncat(). --- cfg/std.cfg | 1 + test/cfg/std.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/cfg/std.cfg b/cfg/std.cfg index 7de265506..8d6769cf7 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -4982,6 +4982,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 c252ddaa0..163c6957c 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -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: