diff --git a/cfg/std.cfg b/cfg/std.cfg index 286e78854..981bd392b 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -4829,6 +4829,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun + @@ -4837,6 +4838,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun + diff --git a/test/cfg/std.c b/test/cfg/std.c index b08b1e407..66ebb2868 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -3400,6 +3400,26 @@ void uninitvar_wcscpy(wchar_t *d, wchar_t*s) (void)wcscpy(d,s); } +size_t bufferAccessOutOfBounds_strftime(char *s, size_t max, const char *fmt, const struct tm *p) +{ + char buf[42] = {0}; + // cppcheck-suppress bufferAccessOutOfBounds + (void) strftime(buf,43,fmt,p); + (void) strftime(buf,max,fmt,p); + return strftime(buf,42,fmt,p); +} + +size_t nullPointer_strftime(char *s, size_t max, const char *fmt, const struct tm *p) +{ + // cppcheck-suppress nullPointer + (void) strftime(NULL,max,fmt,p); + // cppcheck-suppress nullPointer + (void) strftime(s,max,NULL,p); + // cppcheck-suppress nullPointer + (void) strftime(s,max,fmt,NULL); + return strftime(s,max,fmt,p); +} + void uninitvar_strftime(void) { char *s; diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index fa717befe..9e54f5e53 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -31,6 +31,17 @@ #include #include +size_t nullPointer_strftime(char *s, size_t max, const char *fmt, const struct tm *p) +{ + // cppcheck-suppress nullPointer + (void) std::strftime(NULL,max,fmt,p); + // cppcheck-suppress nullPointer + (void) std::strftime(s,max,NULL,p); + // cppcheck-suppress nullPointer + (void) std::strftime(s,max,fmt,NULL); + return std::strftime(s,max,fmt,p); +} + size_t bufferAccessOutOfBounds_wcsrtombs(char * dest, const wchar_t ** src, size_t len, mbstate_t * ps) { char buf[42];