summaryrefslogtreecommitdiffstats
path: root/pwcache.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2020-09-02 10:05:54 -0400
committerTavian Barnes <tavianator@tavianator.com>2020-09-02 10:05:54 -0400
commit72cfcb1fa636017611ce0aeddbe2970003a01cfa (patch)
tree19fa1f6e46a3f1a39d2b50ab532b6fbab6000405 /pwcache.c
parent05a04ee57e52980e9d651ee6e1764ba6f0e4ea1c (diff)
downloadbfs-72cfcb1fa636017611ce0aeddbe2970003a01cfa.tar.xz
pwcache: Fix an invalid free if strdup()ing the group name fails
Diffstat (limited to 'pwcache.c')
-rw-r--r--pwcache.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/pwcache.c b/pwcache.c
index d488625..70869bb 100644
--- a/pwcache.c
+++ b/pwcache.c
@@ -193,16 +193,17 @@ struct bfs_groups *bfs_parse_groups(void) {
error = errno;
goto fail_end;
}
-
ent = groups->entries + darray_length(groups->entries) - 1;
+
+ void *members = ent->gr_mem;
+ ent->gr_mem = NULL;
+
ent->gr_name = strdup(ent->gr_name);
if (!ent->gr_name) {
error = errno;
goto fail_end;
}
- void *members = ent->gr_mem;
- ent->gr_mem = NULL;
for (char *mem = next_gr_mem(&members); mem; mem = next_gr_mem(&members)) {
char *dup = strdup(mem);
if (!dup) {