Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ add_list(/*@returned@*/ /*@only@*/char **list, const char *member)
tmp[i] = xstrdup (member);
tmp[i+1] = NULL;

free (list);

return tmp;
}

Comment thread
alejandro-colomar marked this conversation as resolved.
Expand Down Expand Up @@ -119,11 +121,15 @@ del_list(/*@returned@*/ /*@only@*/char **list, const char *member)
if (!streq(list[i], member)) {
tmp[j] = list[i];
j++;
} else {
free (list[i]);
Comment thread
alejandro-colomar marked this conversation as resolved.
}
}

tmp[j] = NULL;

free (list);

Comment thread
alejandro-colomar marked this conversation as resolved.
return tmp;
}

Expand Down
16 changes: 11 additions & 5 deletions src/groupadd.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ static const char Prog[] = "groupadd";
static /*@null@*/char *group_name;
static gid_t group_id;
static /*@null@*/char *group_passwd;
static /*@null@*/char *empty_list = NULL;

static const char *prefix = "";
static char *user_list;

Expand Down Expand Up @@ -151,7 +149,7 @@ static void new_grent (struct group *grent)
grent->gr_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */
}
grent->gr_gid = group_id;
grent->gr_mem = &empty_list;
grent->gr_mem = comma_to_list("");
}

#ifdef SHADOWGRP
Expand All @@ -170,8 +168,8 @@ static void new_sgent (struct sgrp *sgent)
} else {
sgent->sg_passwd = "!"; /* XXX warning: const */
}
sgent->sg_adm = &empty_list;
sgent->sg_mem = &empty_list;
sgent->sg_adm = comma_to_list("");
sgent->sg_mem = comma_to_list("");
Comment thread
alejandro-colomar marked this conversation as resolved.
}
#endif /* SHADOWGRP */

Expand Down Expand Up @@ -247,6 +245,14 @@ grp_update(void)
Prog, sgr_dbname (), sgrp.sg_namp);
fail_exit (E_GRP_UPDATE);
}
#endif /* SHADOWGRP */
free_list(grp.gr_mem);
free(grp.gr_mem);
#ifdef SHADOWGRP
free_list(sgrp.sg_mem);
free(sgrp.sg_mem);
free_list(sgrp.sg_adm);
free(sgrp.sg_adm);
#endif /* SHADOWGRP */
}

Expand Down
18 changes: 13 additions & 5 deletions src/groupmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ grp_update(void)
sgrp.sg_namp = xstrdup (grp.gr_name);
sgrp.sg_passwd = xstrdup (grp.gr_passwd);
sgrp.sg_adm = ∅
sgrp.sg_mem = dup_list (grp.gr_mem);
sgrp.sg_mem = grp.gr_mem;
Comment thread
alejandro-colomar marked this conversation as resolved.
Comment thread
alejandro-colomar marked this conversation as resolved.
new_sgent (&sgrp);
osgrp = &sgrp; /* entry needs to be committed */
}
Expand All @@ -259,17 +259,15 @@ grp_update(void)
grp.gr_mem[0] = NULL;
} else {
// append to existing groups
if (NULL != grp.gr_mem[0])
grp.gr_mem = dup_list (grp.gr_mem);
grp.gr_mem = dup_list (grp.gr_mem);
}
Comment thread
alejandro-colomar marked this conversation as resolved.
#ifdef SHADOWGRP
if (NULL != osgrp) {
if (!aflg) {
sgrp.sg_mem = xmalloc_T(1, char *);
sgrp.sg_mem[0] = NULL;
} else {
if (NULL != sgrp.sg_mem[0])
sgrp.sg_mem = dup_list(sgrp.sg_mem);
sgrp.sg_mem = dup_list(sgrp.sg_mem);
}
}
Comment thread
alejandro-colomar marked this conversation as resolved.
Comment thread
alejandro-colomar marked this conversation as resolved.
#endif /* SHADOWGRP */
Expand Down Expand Up @@ -327,6 +325,16 @@ grp_update(void)
}
}
#endif /* SHADOWGRP */
if (NULL != user_list) {
free_list(grp.gr_mem);
free(grp.gr_mem);
#ifdef SHADOWGRP
if (NULL != osgrp) {
free_list(sgrp.sg_mem);
free(sgrp.sg_mem);
}
#endif /* SHADOWGRP */
}
Comment thread
alejandro-colomar marked this conversation as resolved.
}

/*
Expand Down
Loading