Skip to content

Commit

Permalink
Make grp tallo'c, too
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Oct 5, 2014
1 parent a2f0a06 commit 3b719f7
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/modules/rlm_unix/rlm_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,20 @@ static const CONF_PARSER module_config[] = {
#else
static struct group *fr_getgrnam(TALLOC_CTX *ctx, char const *name)
{
struct group *grp, my_group;
struct group *grp, *result;
char *group_buffer;
size_t group_size = 1024;

grp = NULL;
group_buffer = talloc_array(ctx, char, group_size);
grp = talloc(ctx, struct group);
group_buffer = talloc_array(grp, char, group_size);
while (group_buffer) {
int err;

err = getgrnam_r(name, &my_group, group_buffer, group_size, &grp);
err = getgrnam_r(name, grp, group_buffer, group_size, &result);
if (err == ERANGE) {
group_size *= 2;
talloc_free(group_buffer);
group_buffer = talloc_array(ctx, char, group_size);
group_buffer = talloc_array(grp, char, group_size);
continue;
}

Expand Down Expand Up @@ -145,6 +145,10 @@ static int groupcmp(UNUSED void *instance, REQUEST *req, UNUSED VALUE_PAIR *requ
}
}

#ifdef HAVE_GETGRNAM_R
talloc_free(grp);
#endif

return retval;
}

Expand Down

0 comments on commit 3b719f7

Please sign in to comment.