Skip to content

Commit ba57f33

Browse files
committed
posix.cfg: Added support for getgrnam_r() and getgrgid_r().
1 parent 28da263 commit ba57f33

2 files changed

Lines changed: 79 additions & 0 deletions

File tree

cfg/posix.cfg

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4740,6 +4740,60 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s
47404740
</arg>
47414741
<warn severity="portability">Non reentrant function 'getgrgid' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getgrgid_r'.</warn>
47424742
</function>
4743+
<!-- https://man7.org/linux/man-pages/man3/getgrnam.3.html -->
4744+
<!-- int getgrnam_r(const char *restrict name, struct group *restrict grp, char *restrict buf, size_t buflen, struct group **restrict result); -->
4745+
<function name="getgrnam_r">
4746+
<returnValue type="int"/>
4747+
<use-retval/>
4748+
<noreturn>false</noreturn>
4749+
<leak-ignore/>
4750+
<arg nr="1" direction="in">
4751+
<not-null/>
4752+
<not-uninit/>
4753+
<not-bool/>
4754+
</arg>
4755+
<arg nr="2" direction="out">
4756+
<not-null/>
4757+
</arg>
4758+
<arg nr="3" direction="out">
4759+
<not-null/>
4760+
<minsize type="argvalue" arg="4"/>
4761+
</arg>
4762+
<arg nr="4" direction="in">
4763+
<not-uninit/>
4764+
<valid>0:</valid>
4765+
</arg>
4766+
<arg nr="5" direction="out">
4767+
<not-null/>
4768+
</arg>
4769+
</function>
4770+
<!-- https://man7.org/linux/man-pages/man3/getgrnam.3.html -->
4771+
<!-- int getgrgid_r(gid_t gid, struct group *restrict grp, char *restrict buf, size_t buflen, struct group **restrict result); -->
4772+
<function name="getgrgid_r">
4773+
<returnValue type="int"/>
4774+
<use-retval/>
4775+
<noreturn>false</noreturn>
4776+
<leak-ignore/>
4777+
<arg nr="1" direction="in">
4778+
<not-null/>
4779+
<not-uninit/>
4780+
<not-bool/>
4781+
</arg>
4782+
<arg nr="2" direction="out">
4783+
<not-null/>
4784+
</arg>
4785+
<arg nr="3" direction="out">
4786+
<not-null/>
4787+
<minsize type="argvalue" arg="4"/>
4788+
</arg>
4789+
<arg nr="4" direction="in">
4790+
<not-uninit/>
4791+
<valid>0:</valid>
4792+
</arg>
4793+
<arg nr="5" direction="out">
4794+
<not-null/>
4795+
</arg>
4796+
</function>
47434797
<!-- char *getlogin(void); -->
47444798
<function name="getlogin">
47454799
<returnValue type="char *"/>

test/cfg/posix.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <sys/sem.h>
1717
#include <sys/time.h>
1818
#include <sys/types.h>
19+
#include <grp.h>
1920
#include <dlfcn.h>
2021
#include <fcntl.h>
2122
// unavailable on some linux systems #include <ndbm.h>
@@ -33,6 +34,30 @@
3334
#include <string.h>
3435
#include <strings.h>
3536

37+
int nullPointer_getgrgid_r(gid_t gid, struct group *restrict grp, char *restrict buf, size_t buflen, struct group **restrict result)
38+
{
39+
// cppcheck-suppress nullPointer
40+
(void) getgrgid_r(gid, NULL, buf, buflen, result);
41+
// cppcheck-suppress nullPointer
42+
(void) getgrgid_r(gid, grp, NULL, buflen, result);
43+
// cppcheck-suppress nullPointer
44+
(void) getgrgid_r(gid, grp, buf, buflen, NULL);
45+
return getgrgid_r(gid, grp, buf, buflen, result);
46+
}
47+
48+
int nullPointer_getgrnam_r(const char *restrict name, struct group *restrict grp, char *restrict buf, size_t buflen, struct group **restrict result)
49+
{
50+
// cppcheck-suppress nullPointer
51+
(void) getgrnam_r(NULL, grp, buf, buflen, result);
52+
// cppcheck-suppress nullPointer
53+
(void) getgrnam_r(name, NULL, buf, buflen, result);
54+
// cppcheck-suppress nullPointer
55+
(void) getgrnam_r(name, grp, NULL, buflen, result);
56+
// cppcheck-suppress nullPointer
57+
(void) getgrnam_r(name, grp, buf, buflen, NULL);
58+
return getgrnam_r(name, grp, buf, buflen, result);
59+
}
60+
3661
void knownConditionTrueFalse_ffs(int i)
3762
{
3863
// ffs() returns the position of the first bit set, or 0 if no bits are set in i.

0 commit comments

Comments
 (0)