Skip to content

Commit

Permalink
LibC: Don't clear static storage during endgrent
Browse files Browse the repository at this point in the history
The POSIX documentation for `endgrent` only mentions that it "closes
the group database", not that it clears the backing storage for return
values. This means that applications might make use of the returned
values even after closing the group database itself. This includes our
own implementations for `getgrnam` and `getgrgid`.

The specification also states that "the storage areas might be
overwritten by a subsequent call to `getgrgid`, `getgrnam`, or
`getgrent`". This implies that `getgrgid` and `getgrnam` aren't meant
to have their own static storage and instead rely on the storage of
`getgrent`.
  • Loading branch information
timschumi authored and linusg committed Jul 6, 2022
1 parent d2b7d24 commit d903af3
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions Userland/Libraries/LibC/grp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@ void endgrent()
fclose(s_stream);
s_stream = nullptr;
}

memset(&s_group, 0, sizeof(s_group));

s_name = {};
s_passwd = {};
s_members = {};
s_members_ptrs = {};
}

struct group* getgrgid(gid_t gid)
Expand Down

0 comments on commit d903af3

Please sign in to comment.