Skip to content

Commit 1fb1b22

Browse files
committed
posix.cfg: Improved configuration for bzero() and added tests.
1 parent 7c9b9a6 commit 1fb1b22

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

cfg/posix.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3983,6 +3983,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
39833983
<leak-ignore/>
39843984
<arg nr="1" direction="out">
39853985
<not-null/>
3986+
<minsize type="argvalue" arg="2"/>
39863987
</arg>
39873988
<arg nr="2" direction="in">
39883989
<not-uninit/>

test/cfg/posix.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,29 @@ int nullPointer_bcmp(const void *a, const void *b, size_t n)
249249
return bcmp(NULL, b, n);
250250
}
251251

252+
void nullPointer_bzero(void *s, size_t n)
253+
{
254+
// cppcheck-suppress nullPointer
255+
// cppcheck-suppress bzeroCalled
256+
bzero(NULL,n);
257+
// No nullPointer-warning shall be shown:
258+
// cppcheck-suppress bzeroCalled
259+
bzero(s,n);
260+
}
261+
262+
void bufferAccessOutOfBounds_bzero(void *s, size_t n)
263+
{
264+
char buf[42];
265+
// cppcheck-suppress bufferAccessOutOfBounds
266+
// cppcheck-suppress bzeroCalled
267+
bzero(buf,43);
268+
// cppcheck-suppress bzeroCalled
269+
bzero(buf,42);
270+
// No nullPointer-warning shall be shown:
271+
// cppcheck-suppress bzeroCalled
272+
bzero(s,n);
273+
}
274+
252275
char * nullPointer_stpcpy(char *src, char *dest)
253276
{
254277
// No warning shall be shown:

0 commit comments

Comments
 (0)