diff options
author | Tobias Brunner <tobias@strongswan.org> | 2013-07-24 08:43:10 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2013-07-24 10:54:26 +0200 |
commit | cfdd23b96710dbfe94d5d3f5bb9c23afa0b80e98 (patch) | |
tree | 367712f0c869c54383e86632f21bca89597c8618 /src | |
parent | 3021139f6febab5f0510257e9911c9a5374c9599 (diff) | |
download | strongswan-cfdd23b96710dbfe94d5d3f5bb9c23afa0b80e98.tar.bz2 strongswan-cfdd23b96710dbfe94d5d3f5bb9c23afa0b80e98.tar.xz |
capabilities: Proper error handling when reading groups
Diffstat (limited to 'src')
-rw-r--r-- | src/libstrongswan/utils/capabilities.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/libstrongswan/utils/capabilities.c b/src/libstrongswan/utils/capabilities.c index 31a7291c9..c5e90b6c3 100644 --- a/src/libstrongswan/utils/capabilities.c +++ b/src/libstrongswan/utils/capabilities.c @@ -90,12 +90,19 @@ static bool has_group(gid_t group) return TRUE; } ngroups = sysconf(_SC_NGROUPS_MAX); - groups = calloc(ngroups, sizeof(gid_t)); + if (ngroups == -1) + { + DBG1(DBG_LIB, "getting groups for current process failed: %s", + strerror(errno)); + return FALSE; + } + groups = calloc(ngroups + 1, sizeof(gid_t)); ngroups = getgroups(ngroups, groups); if (ngroups == -1) { DBG1(DBG_LIB, "getting groups for current process failed: %s", strerror(errno)); + free(groups); return FALSE; } for (i = 0; i < ngroups; i++) |