posix.cfg: Fixed bufferAccessOutOfBounds falsen negative for strnlen() and added a TODO for wcsnlen()

This commit is contained in:
orbitcowboy 2022-04-21 09:02:02 +02:00
parent dad1a68e51
commit 3bd65d42cd
2 changed files with 27 additions and 0 deletions

View File

@ -4723,6 +4723,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
<minsize type="argvalue" arg="2"/>
</arg>
<arg nr="2" direction="in">
<not-uninit/>

View File

@ -48,6 +48,15 @@ int nullPointer_wcsnlen(const wchar_t *s, size_t n)
return wcsnlen(s, n);
}
size_t bufferAccessOutOfBounds_wcsnlen(const wchar_t *s, size_t maxlen)
{
wchar_t buf[2]={L'4',L'2'};
size_t len = wcsnlen(buf,2);
// TODO cppcheck-suppress bufferAccessOutOfBounds
len+=wcsnlen(buf,3);
return len;
}
int nullPointer_gethostname(char *s, size_t n)
{
// cppcheck-suppress nullPointer
@ -272,6 +281,23 @@ void bufferAccessOutOfBounds_bzero(void *s, size_t n)
bzero(s,n);
}
size_t bufferAccessOutOfBounds_strnlen(const char *s, size_t maxlen)
{
char buf[2]={'4','2'};
size_t len = strnlen(buf,2);
// cppcheck-suppress bufferAccessOutOfBounds
len+=strnlen(buf,3);
return len;
}
size_t nullPointer_strnlen(const char *s, size_t maxlen)
{
// No warning shall be shown:
(void) strnlen(s, maxlen);
// cppcheck-suppress nullPointer
return strnlen(NULL, maxlen);
}
char * nullPointer_stpcpy(char *src, char *dest)
{
// No warning shall be shown: