From 1fb1b22bae2d7f52184da99fe2216e2e9284eec6 Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Wed, 20 Apr 2022 20:57:58 +0200 Subject: [PATCH] posix.cfg: Improved configuration for bzero() and added tests. --- cfg/posix.cfg | 1 + test/cfg/posix.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/cfg/posix.cfg b/cfg/posix.cfg index 55b8ff243..37801fe58 100644 --- a/cfg/posix.cfg +++ b/cfg/posix.cfg @@ -3983,6 +3983,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s + diff --git a/test/cfg/posix.c b/test/cfg/posix.c index 3aa38c14c..ed5e7bb11 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -249,6 +249,29 @@ int nullPointer_bcmp(const void *a, const void *b, size_t n) return bcmp(NULL, b, n); } +void nullPointer_bzero(void *s, size_t n) +{ + // cppcheck-suppress nullPointer + // cppcheck-suppress bzeroCalled + bzero(NULL,n); + // No nullPointer-warning shall be shown: + // cppcheck-suppress bzeroCalled + bzero(s,n); +} + +void bufferAccessOutOfBounds_bzero(void *s, size_t n) +{ + char buf[42]; + // cppcheck-suppress bufferAccessOutOfBounds + // cppcheck-suppress bzeroCalled + bzero(buf,43); + // cppcheck-suppress bzeroCalled + bzero(buf,42); + // No nullPointer-warning shall be shown: + // cppcheck-suppress bzeroCalled + bzero(s,n); +} + char * nullPointer_stpcpy(char *src, char *dest) { // No warning shall be shown: