Skip to content

Commit 8cc16f1

Browse files
committed
posix.cfg: Improved configuration of getpwnam_r().
1 parent 67f4fe5 commit 8cc16f1

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

cfg/posix.cfg

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3366,9 +3366,13 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
33663366
<noreturn>false</noreturn>
33673367
<arg nr="1" direction="in">
33683368
<not-uninit/>
3369+
<not-null/>
3370+
</arg>
3371+
<arg nr="2" direction="out">
3372+
<not-null/>
33693373
</arg>
3370-
<arg nr="2" direction="out"/>
33713374
<arg nr="3" direction="out">
3375+
<not-null/>
33723376
<minsize type="argvalue" arg="4"/>
33733377
</arg>
33743378
<arg nr="4" direction="in">
@@ -3378,6 +3382,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
33783382
</arg>
33793383
<arg nr="5" direction="out">
33803384
<not-bool/>
3385+
<not-null/>
33813386
</arg>
33823387
</function>
33833388
<!-- struct passwd *getpwuid(uid_t uid); -->

test/cfg/posix.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@
3535
#include <string.h>
3636
#include <strings.h>
3737

38+
int nullPointer_getpwnam_r(const char *name, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result)
39+
{
40+
// cppcheck-suppress nullPointer
41+
(void) getpwnam_r(NULL, pwd, buffer, bufsize, result);
42+
// cppcheck-suppress nullPointer
43+
(void) getpwnam_r(name, NULL, buffer, bufsize, result);
44+
// cppcheck-suppress nullPointer
45+
(void) getpwnam_r(name, pwd, NULL, bufsize, result);
46+
// cppcheck-suppress nullPointer
47+
(void) getpwnam_r(name, pwd, buffer, bufsize, NULL);
48+
return getpwnam_r(name, pwd, buffer, bufsize, result);
49+
}
50+
3851
int nullPointer_fgetpwent_r(FILE *restrict stream, struct passwd *restrict pwbuf, char *restrict buf, size_t buflen, struct passwd **restrict pwbufp)
3952
{
4053
// cppcheck-suppress nullPointer

0 commit comments

Comments
 (0)