Skip to content

Commit

Permalink
std.cfg: Fixed bufferAccessOutOfBounds false negative for strncmp().
Browse files Browse the repository at this point in the history
  • Loading branch information
orbitcowboy committed Apr 13, 2021
1 parent 03bdcc4 commit f62d9d5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cfg/std.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5000,10 +5000,14 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
<strz/>
<minsize type="argvalue" arg="3"/>
</arg>
<arg nr="2" direction="in">
<not-null/>
<not-uninit/>
<strz/>
<minsize type="argvalue" arg="3"/>
</arg>
<arg nr="3" direction="in">
<not-uninit/>
Expand Down
11 changes: 11 additions & 0 deletions test/cfg/std.c
Original file line number Diff line number Diff line change
Expand Up @@ -3561,6 +3561,17 @@ void bufferAccessOutOfBounds_strxfrm(void)
(void)strxfrm(dest,src,3);
}

void bufferAccessOutOfBounds_strncmp(void)
{
const char src[3] = "abc";
char dest[1] = "a";
(void)strncmp(dest,src,1);
// cppcheck-suppress bufferAccessOutOfBounds
(void)strncmp(dest,src,2);
// cppcheck-suppress bufferAccessOutOfBounds
(void)strncmp(dest,src,3);
}

void uninitvar_wcsxfrm(void)
{
wchar_t *ds;
Expand Down

0 comments on commit f62d9d5

Please sign in to comment.