From d1b6954dd8a08a7c2fd98d6a8456a06babc5f79e Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Mon, 25 Apr 2022 18:25:52 +0200 Subject: [PATCH] std.cfg: Improved configuration for wcsrtombs(). --- cfg/std.cfg | 4 +++- test/cfg/std.c | 9 +++++++++ test/cfg/std.cpp | 9 +++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/cfg/std.cfg b/cfg/std.cfg index bb881cb43..a755f81f8 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -5331,7 +5331,9 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun false - + + + diff --git a/test/cfg/std.c b/test/cfg/std.c index 81115f2f5..bd6a93448 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -25,6 +25,15 @@ #include #include +size_t bufferAccessOutOfBounds_wcsrtombs(char * dest, const wchar_t ** src, size_t len, mbstate_t * ps) +{ + char buf[42]; + (void)wcsrtombs(buf,src,42,ps); + // cppcheck-suppress bufferAccessOutOfBounds + (void)wcsrtombs(buf,src,43,ps); + return wcsrtombs(dest,src,len,ps); +} + void bufferAccessOutOfBounds(void) { char a[5]; diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index b7273cf61..fa717befe 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -31,6 +31,15 @@ #include #include +size_t bufferAccessOutOfBounds_wcsrtombs(char * dest, const wchar_t ** src, size_t len, mbstate_t * ps) +{ + char buf[42]; + (void)std::wcsrtombs(buf,src,42,ps); + // cppcheck-suppress bufferAccessOutOfBounds + (void)std::wcsrtombs(buf,src,43,ps); + return std::wcsrtombs(dest,src,len,ps); +} + void invalidFunctionArg_std_string_substr(const std::string &str, std::size_t pos, std::size_t len) { // cppcheck-suppress invalidFunctionArg (void)str.substr(-1,len);