posix.cfg: Improved configuration of getpwuid_r().

This commit is contained in:
orbitcowboy 2022-05-02 16:48:22 +02:00
parent 8cc16f1adb
commit 5a7c998a79
2 changed files with 19 additions and 3 deletions

View File

@ -3396,17 +3396,21 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
</arg>
<warn severity="portability">Non reentrant function 'getpwuid' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getpwuid_r'.</warn>
</function>
<!-- https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpwuid.html -->
<!-- int getpwuid_r(uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result); -->
<!-- https://man7.org/linux/man-pages/man3/getpwnam.3.html -->
<!-- int getpwuid_r(uid_t uid, struct passwd *restrict pwd, char *restrict buf, size_t buflen, struct passwd **restrict result) -->
<function name="getpwuid_r">
<returnValue type="int"/>
<use-retval/>
<noreturn>false</noreturn>
<arg nr="1" direction="in">
<not-uninit/>
<not-bool/>
</arg>
<arg nr="2" direction="out"/>
<arg nr="2" direction="out">
<not-null/>
</arg>
<arg nr="3" direction="out">
<not-null/>
<minsize type="argvalue" arg="4"/>
</arg>
<arg nr="4" direction="in">
@ -3416,6 +3420,7 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
</arg>
<arg nr="5" direction="out">
<not-bool/>
<not-null/>
</arg>
</function>
<!-- void setpwent(void); -->

View File

@ -35,6 +35,17 @@
#include <string.h>
#include <strings.h>
int nullPointer_getpwuid_r(uid_t uid, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result)
{
// cppcheck-suppress nullPointer
(void) getpwuid_r(uid, NULL, buffer, bufsize, result);
// cppcheck-suppress nullPointer
(void) getpwuid_r(uid, pwd, NULL, bufsize, result);
// cppcheck-suppress nullPointer
(void) getpwuid_r(uid, pwd, buffer, bufsize, NULL);
return getpwuid_r(uid, pwd, buffer, bufsize, result);
}
int nullPointer_getpwnam_r(const char *name, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result)
{
// cppcheck-suppress nullPointer