From ba57f33f81d512278ba500d94998fcffeb737514 Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Mon, 2 May 2022 12:28:54 +0200 Subject: [PATCH] posix.cfg: Added support for getgrnam_r() and getgrgid_r(). --- cfg/posix.cfg | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ test/cfg/posix.c | 25 ++++++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/cfg/posix.cfg b/cfg/posix.cfg index f79f473ab..5af9a3f20 100644 --- a/cfg/posix.cfg +++ b/cfg/posix.cfg @@ -4740,6 +4740,60 @@ The function 'mktemp' is considered to be dangerous due to race conditions and s Non reentrant function 'getgrgid' called. For threadsafe applications it is recommended to use the reentrant replacement function 'getgrgid_r'. + + + + + + false + + + + + + + + + + + + + + + + 0: + + + + + + + + + + + false + + + + + + + + + + + + + + + + 0: + + + + + diff --git a/test/cfg/posix.c b/test/cfg/posix.c index 07010c84b..826976c49 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include // unavailable on some linux systems #include @@ -33,6 +34,30 @@ #include #include +int nullPointer_getgrgid_r(gid_t gid, struct group *restrict grp, char *restrict buf, size_t buflen, struct group **restrict result) +{ + // cppcheck-suppress nullPointer + (void) getgrgid_r(gid, NULL, buf, buflen, result); + // cppcheck-suppress nullPointer + (void) getgrgid_r(gid, grp, NULL, buflen, result); + // cppcheck-suppress nullPointer + (void) getgrgid_r(gid, grp, buf, buflen, NULL); + return getgrgid_r(gid, grp, buf, buflen, result); +} + +int nullPointer_getgrnam_r(const char *restrict name, struct group *restrict grp, char *restrict buf, size_t buflen, struct group **restrict result) +{ + // cppcheck-suppress nullPointer + (void) getgrnam_r(NULL, grp, buf, buflen, result); + // cppcheck-suppress nullPointer + (void) getgrnam_r(name, NULL, buf, buflen, result); + // cppcheck-suppress nullPointer + (void) getgrnam_r(name, grp, NULL, buflen, result); + // cppcheck-suppress nullPointer + (void) getgrnam_r(name, grp, buf, buflen, NULL); + return getgrnam_r(name, grp, buf, buflen, result); +} + void knownConditionTrueFalse_ffs(int i) { // ffs() returns the position of the first bit set, or 0 if no bits are set in i.