aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2011-07-01 12:54:51 -0400
committerNick Mathewson <nickm@torproject.org>2011-07-01 12:54:51 -0400
commit021cf3f0521375f1722a7fb82ce286086db79142 (patch)
tree8e6f5b41e94da33d2f9450b2cad1f6c3219aa7d2 /src
parent959da6b7f2b5ed63426fd12a9046ac06033f6db1 (diff)
parentd25feadebbf05d6fce55cfee1e3c8f928903f543 (diff)
downloadtor-021cf3f0521375f1722a7fb82ce286086db79142.tar
tor-021cf3f0521375f1722a7fb82ce286086db79142.tar.gz
Merge branches 'cov217_021' and 'cid_450' into maint-0.2.1
Diffstat (limited to 'src')
-rw-r--r--src/common/compat.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index 39651084a..9533c115b 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -1080,7 +1080,8 @@ log_credential_status(void)
/* Read, effective and saved GIDs */
gid_t rgid, egid, sgid;
/* Supplementary groups */
- gid_t sup_gids[NGROUPS_MAX + 1];
+ gid_t *sup_gids = NULL;
+ int sup_gids_size;
/* Number of supplementary groups */
int ngids;
@@ -1126,9 +1127,19 @@ log_credential_status(void)
#endif
/* log supplementary groups */
- if ((ngids = getgroups(NGROUPS_MAX + 1, sup_gids)) < 0) {
+ sup_gids_size = 64;
+ sup_gids = tor_malloc(sizeof(gid_t) * 64);
+ while ((ngids = getgroups(sup_gids_size, sup_gids)) < 0 &&
+ errno == EINVAL &&
+ sup_gids_size < NGROUPS_MAX) {
+ sup_gids_size *= 2;
+ sup_gids = tor_realloc(sup_gids, sizeof(gid_t) * sup_gids_size);
+ }
+
+ if (ngids < 0) {
log_warn(LD_GENERAL, "Error getting supplementary GIDs: %s",
strerror(errno));
+ tor_free(sup_gids);
return -1;
} else {
int i, retval = 0;
@@ -1158,6 +1169,7 @@ log_credential_status(void)
tor_free(cp);
});
smartlist_free(elts);
+ tor_free(sup_gids);
return retval;
}