Skip to content

Commit

Permalink
pwcache: Fix an invalid free if strdup()ing the group name fails
Browse files Browse the repository at this point in the history
  • Loading branch information
tavianator committed Sep 2, 2020
1 parent 05a04ee commit 72cfcb1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pwcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 72cfcb1

Please sign in to comment.