std.cfg: Improved configuration of strpbrk() and added regression tests. These cases were found in the wild (daca@home: ftp://ftp.de.debian.org/debian/pool/main/i/ion/ion_3.2.1+dfsg.orig.tar.gz, ion-open-source/contrib/dtnperf/dtnperf/src/utils.c:71:32: error: Invalid strpbrk() argument nr 2. A nul-terminated string is required. [invalidFunctionArgStr]).

This commit is contained in:
orbitcowboy 2022-06-03 08:36:25 +02:00
parent c24edc528e
commit 8382ea7692
2 changed files with 14 additions and 0 deletions

View File

@ -5020,6 +5020,7 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
<strz/>
</arg>
<arg nr="2" direction="in">
<not-null/>

View File

@ -29,6 +29,19 @@
#include <inttypes.h>
#include <float.h>
char * invalidFunctionArgStr_strpbrk( const char *p )
{
const char search[] = { -42, -43, -44 };
const char pattern[3] = { -42, -43, -44 };
(void) strpbrk( "abc42", "42" );
// cppcheck-suppress invalidFunctionArgStr
(void) strpbrk( search, "42" );
// cppcheck-suppress invalidFunctionArgStr
(void) strpbrk( search, pattern );
// cppcheck-suppress invalidFunctionArgStr
return strpbrk( p, pattern );
}
int invalidFunctionArgStr_strncmp( const char *p )
{
// No warning is expected for: