diff --git a/cfg/std.cfg b/cfg/std.cfg index 0d7462aa1..86ce3954a 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -5137,12 +5137,10 @@ The obsolete function 'gets' is called. With 'gets' you'll get a buffer overrun - - diff --git a/test/cfg/std.c b/test/cfg/std.c index 684c4dd7a..9ca3a61f0 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -75,6 +75,11 @@ char * invalidFunctionArgStr_strpbrk( const char *p ) int invalidFunctionArgStr_strncmp( const char *p ) { + const char string[] = "foo"; + char other[5] = { 0 }; + memcpy(other, "foo", 4); + if (strncmp(other, string, 5) != 0) {} + // No warning is expected for: const char emdash[3] = { -42, -43, -44 }; return strncmp( p, emdash, 3 ); @@ -3921,9 +3926,7 @@ 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); }