std.cfg: Improved configuration of strftime().

This commit is contained in:
orbitcowboy 2022-04-26 18:01:57 +02:00
parent 474c7fe5cc
commit 17189e1d6e
3 changed files with 33 additions and 0 deletions

View File

@ -4829,6 +4829,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<leak-ignore/> <leak-ignore/>
<arg nr="1" direction="out"> <arg nr="1" direction="out">
<not-null/> <not-null/>
<minsize type="argvalue" arg="2"/>
</arg> </arg>
<arg nr="2" direction="in"> <arg nr="2" direction="in">
<not-uninit/> <not-uninit/>
@ -4837,6 +4838,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<arg nr="3" direction="in"> <arg nr="3" direction="in">
<not-null/> <not-null/>
<not-uninit/> <not-uninit/>
<formatstr/>
</arg> </arg>
<arg nr="4" direction="in"> <arg nr="4" direction="in">
<not-null/> <not-null/>

View File

@ -3400,6 +3400,26 @@ void uninitvar_wcscpy(wchar_t *d, wchar_t*s)
(void)wcscpy(d,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) void uninitvar_strftime(void)
{ {
char *s; char *s;

View File

@ -31,6 +31,17 @@
#include <iterator> #include <iterator>
#include <vector> #include <vector>
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) size_t bufferAccessOutOfBounds_wcsrtombs(char * dest, const wchar_t ** src, size_t len, mbstate_t * ps)
{ {
char buf[42]; char buf[42];