Skip to content

Commit

Permalink
Fix incorrect getgrnam error handling
Browse files Browse the repository at this point in the history
getgrent(3) says:

    Note that programs must explicitly set errno to zero before calling any
    of these functions if they need to distinguish between a non-existent
    entry and an error.

We didn't so we could log the wrong error based on previous failed call
and confuse the user.

Signed-off-by: Nir Soffer <[email protected]>
  • Loading branch information
nirs committed Sep 17, 2024
1 parent 8513f80 commit 74644f8
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ static int socket_bindlisten(const char *socket_path,
goto err;
}
if (socket_group != NULL) {
errno = 0;
struct group *grp = getgrnam(socket_group); /* Do not free */
if (grp == NULL) {
if (errno != 0)
Expand Down

0 comments on commit 74644f8

Please sign in to comment.