dovecot: Setting extra groups crashed.
dovecot at dovecot.org
dovecot at dovecot.org
Sun Jan 6 05:16:36 EET 2008
details: http://hg.dovecot.org/dovecot/rev/fe42e3097e23
changeset: 7124:fe42e3097e23
user: Timo Sirainen <tss at iki.fi>
date: Sun Jan 06 05:16:32 2008 +0200
description:
Setting extra groups crashed.
diffstat:
1 file changed, 10 insertions(+), 7 deletions(-)
src/lib/restrict-access.c | 17 ++++++++++-------
diffs (34 lines):
diff -r 25e7c37c7c10 -r fe42e3097e23 src/lib/restrict-access.c
--- a/src/lib/restrict-access.c Sun Jan 06 03:17:20 2008 +0200
+++ b/src/lib/restrict-access.c Sun Jan 06 05:16:32 2008 +0200
@@ -96,7 +96,7 @@ static void fix_groups_list(const char *
static void fix_groups_list(const char *extra_groups, gid_t egid,
bool preserve_existing, bool *have_root_group)
{
- gid_t *gid_list;
+ gid_t *gid_list, *gid_list2;
const char *const *tmp, *empty = NULL;
unsigned int gid_count;
@@ -123,12 +123,15 @@ static void fix_groups_list(const char *
gid_count = 1;
}
- /* add extra groups to gids list */
- for (; *tmp != NULL; tmp++) {
- if (!t_try_realloc(gid_list, (gid_count+1) * sizeof(gid_t)))
- i_unreached();
- gid_list[gid_count++] = get_group_id(*tmp);
- }
+ if (*tmp != NULL) {
+ /* @UNSAFE: add extra groups to gids list */
+ gid_list2 = t_new(gid_t, gid_count + str_array_length(tmp));
+ memcpy(gid_list2, gid_list, gid_count * sizeof(gid_t));
+ for (; *tmp != NULL; tmp++)
+ gid_list2[gid_count++] = get_group_id(*tmp);
+ gid_list = gid_list2;
+ }
+
if (setgroups(gid_count, gid_list) < 0) {
if (errno == EINVAL) {
i_fatal("setgroups(%s) failed: Too many extra groups",
More information about the dovecot-cvs
mailing list