strongswan.org
Wiki/Project Management
Downloads
Gitweb
projects
/
strongswan.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
3021139
)
capabilities: Proper error handling when reading groups
author
Tobias Brunner
<tobias@strongswan.org>
Wed, 24 Jul 2013 06:43:10 +0000
(08:43 +0200)
committer
Tobias Brunner
<tobias@strongswan.org>
Wed, 24 Jul 2013 08:54:26 +0000
(10:54 +0200)
src/libstrongswan/utils/capabilities.c
patch
|
blob
|
history
diff --git
a/src/libstrongswan/utils/capabilities.c
b/src/libstrongswan/utils/capabilities.c
index
31a7291
..
c5e90b6
100644
(file)
--- 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++)