Added a regression test; A real-world test case like this was found by daca@home: ftp://ftp.de.debian.org/debian/pool/main/o/ogdi-dfsg/ogdi-dfsg_4.1.0+ds.orig.tar.gz head ogdi-ogdi_4_1_0/ogdi/c-api/ecsinfo.c:637:26: error: Invalid strcspn() argument nr 2. A nul-terminated string is required. [invalidFunctionArgStr].

This commit is contained in:
orbitcowboy 2022-06-04 19:33:56 +02:00
parent d595c1e6e8
commit 326d340d76
2 changed files with 11 additions and 1 deletions

View File

@ -29,7 +29,7 @@ CPPCHECK_OPT='--check-library --platform=unix64 --enable=information --enable=st
CXX=g++
CXX_OPT='-fsyntax-only -std=c++0x -Wno-format -Wno-format-security -Wno-deprecated-declarations'
CC=gcc
CC_OPT='-Wno-format -Wno-nonnull -Wno-implicit-function-declaration -Wno-deprecated-declarations -Wno-format-security -Wno-nonnull -fsyntax-only'
CC_OPT='-Wno-format -Wno-stringop-overread -Wno-nonnull -Wno-implicit-function-declaration -Wno-deprecated-declarations -Wno-format-security -Wno-nonnull -fsyntax-only'
function get_pkg_config_cflags {
set +e

View File

@ -29,6 +29,16 @@
#include <inttypes.h>
#include <float.h>
int invalidFunctionArgStr_strcpn(void)
{
const char str1[] = "ABCDEF49620910";
const char str2[] = "42";
const char pattern[3] = { -42, -43, -44 };
// cppcheck-suppress invalidFunctionArgStr
(void) strcspn(str1, pattern);
return strcspn(str1, str2);
}
void invalidFunctionArgStr_strncat(void)
{
char str1[20];