Skip to content

Commit 86cc410

Browse files
committed
posix.cfg: Added support for getpwent_r().
1 parent ba57f33 commit 86cc410

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

cfg/posix.cfg

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3271,6 +3271,29 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
32713271
<noreturn>false</noreturn>
32723272
<warn severity="portability">Non reentrant function 'getpwent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getpwent_r'.</warn>
32733273
</function>
3274+
<!-- https://man7.org/linux/man-pages/man3/getpwent_r.3.html-->
3275+
<!-- int getpwent_r(struct passwd *restrict pwbuf, char *restrict buf, size_t buflen, struct passwd **restrict pwbufp); -->
3276+
<function name="getpwent_r">
3277+
<use-retval/>
3278+
<returnValue type="int"/>
3279+
<noreturn>false</noreturn>
3280+
<arg nr="1" direction="in">
3281+
<not-null/>
3282+
<not-uninit/>
3283+
</arg>
3284+
<arg nr="2" direction="out">
3285+
<not-null/>
3286+
<minsize type="argvalue" arg="3"/>
3287+
</arg>
3288+
<arg nr="3" direction="in">
3289+
<not-uninit/>
3290+
<valid>0:</valid>
3291+
</arg>
3292+
<arg nr="4" direction="out">
3293+
<not-null/>
3294+
<not-bool/>
3295+
</arg>
3296+
</function>
32743297
<!--struct passwd *getpwnam(const char *); -->
32753298
<function name="getpwnam">
32763299
<use-retval/>

test/cfg/posix.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <sys/time.h>
1818
#include <sys/types.h>
1919
#include <grp.h>
20+
#include <pwd.h>
2021
#include <dlfcn.h>
2122
#include <fcntl.h>
2223
// unavailable on some linux systems #include <ndbm.h>
@@ -34,6 +35,17 @@
3435
#include <string.h>
3536
#include <strings.h>
3637

38+
int nullPointer_getpwent_r(struct passwd *restrict pwbuf, char *restrict buf, size_t buflen, struct passwd **restrict pwbufp)
39+
{
40+
// cppcheck-suppress nullPointer
41+
(void) getpwent_r(NULL, buf, buflen, pwbufp);
42+
// cppcheck-suppress nullPointer
43+
(void) getpwent_r(pwbuf, NULL, buflen, pwbufp);
44+
// cppcheck-suppress nullPointer
45+
(void) getpwent_r(pwbuf, buf, buflen, NULL);
46+
return getpwent_r(pwbuf, buf, buflen, pwbufp);
47+
}
48+
3749
int nullPointer_getgrgid_r(gid_t gid, struct group *restrict grp, char *restrict buf, size_t buflen, struct group **restrict result)
3850
{
3951
// cppcheck-suppress nullPointer

0 commit comments

Comments
 (0)