posix.cfg: Added support for getpwent_r().

This commit is contained in:
orbitcowboy 2022-05-02 12:51:58 +02:00
parent ba57f33f81
commit 86cc410dc2
2 changed files with 35 additions and 0 deletions

View File

@ -3271,6 +3271,29 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
<noreturn>false</noreturn>
<warn severity="portability">Non reentrant function 'getpwent' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getpwent_r'.</warn>
</function>
<!-- https://man7.org/linux/man-pages/man3/getpwent_r.3.html-->
<!-- int getpwent_r(struct passwd *restrict pwbuf, char *restrict buf, size_t buflen, struct passwd **restrict pwbufp); -->
<function name="getpwent_r">
<use-retval/>
<returnValue type="int"/>
<noreturn>false</noreturn>
<arg nr="1" direction="in">
<not-null/>
<not-uninit/>
</arg>
<arg nr="2" direction="out">
<not-null/>
<minsize type="argvalue" arg="3"/>
</arg>
<arg nr="3" direction="in">
<not-uninit/>
<valid>0:</valid>
</arg>
<arg nr="4" direction="out">
<not-null/>
<not-bool/>
</arg>
</function>
<!--struct passwd *getpwnam(const char *); -->
<function name="getpwnam">
<use-retval/>

View File

@ -17,6 +17,7 @@
#include <sys/time.h>
#include <sys/types.h>
#include <grp.h>
#include <pwd.h>
#include <dlfcn.h>
#include <fcntl.h>
// unavailable on some linux systems #include <ndbm.h>
@ -34,6 +35,17 @@
#include <string.h>
#include <strings.h>
int nullPointer_getpwent_r(struct passwd *restrict pwbuf, char *restrict buf, size_t buflen, struct passwd **restrict pwbufp)
{
// cppcheck-suppress nullPointer
(void) getpwent_r(NULL, buf, buflen, pwbufp);
// cppcheck-suppress nullPointer
(void) getpwent_r(pwbuf, NULL, buflen, pwbufp);
// cppcheck-suppress nullPointer
(void) getpwent_r(pwbuf, buf, buflen, NULL);
return getpwent_r(pwbuf, buf, buflen, pwbufp);
}
int nullPointer_getgrgid_r(gid_t gid, struct group *restrict grp, char *restrict buf, size_t buflen, struct group **restrict result)
{
// cppcheck-suppress nullPointer