test std.cfg: Added more test cases for strcat() functions.

This commit is contained in:
orbitcowboy 2018-05-27 10:16:02 +02:00
parent 10292c1202
commit 5b6e6db376
2 changed files with 31 additions and 2 deletions

View File

@ -2855,6 +2855,20 @@ void uninitvar_strcat(char *dest, const char * const source)
(void)strcat(dest,source);
}
void bufferAccessOutOfBounds_strcat(char *dest, const char * const source)
{
char buf4[4] = {0};
const char * const srcstr3 = "123";
const char * const srcstr4 = "1234";
// @todo #8599 cppcheck-suppress bufferAccessOutOfBounds
(void)strcat(buf4,srcstr4); // off by one issue: strcat is appends \0' at the end
// no warning shall be shown for
(void)strcat(dest,source);
(void)strcat(buf4,srcstr3); // strcat appends '\0' at the end
(void)strcat(dest,srcstr4); // Cppcheck does not know the length of 'dest'
}
void uninitvar_wcscat(wchar_t *dest, const wchar_t * const source)
{
wchar_t *deststr;

View File

@ -2192,21 +2192,36 @@ void uninivar_setvbuf(void)
(void)std::setvbuf(stream,buf,mode,size);
}
void uninivar_strcat(void)
void uninitvar_strcat(char *dest, const char * const source)
{
char *deststr;
char *srcstr;
// cppcheck-suppress uninitvar
(void)std::strcat(deststr,srcstr);
// cppcheck-suppress uninitvar
(void)std::strcat(dest,srcstr);
// cppcheck-suppress uninitvar
(void)std::strcat(deststr,source);
// no warning shall be shown for
(void)std::strcat(dest,source);
}
void uninivar_wcscat(void)
void uninitvar_wcscat(wchar_t *dest, const wchar_t * const source)
{
wchar_t *deststr;
wchar_t *srcstr;
// cppcheck-suppress uninitvar
(void)std::wcscat(deststr,srcstr);
// cppcheck-suppress uninitvar
(void)std::wcscat(dest,srcstr);
// cppcheck-suppress uninitvar
(void)std::wcscat(deststr,source);
// no warning shall be shown for
(void)std::wcscat(dest,source);
}
void uninivar_wcrtomb(void)
{
char *s;