Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getpwuid_r error handling #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fix getpwuid_r error handling #3

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Aug 21, 2020

from man getpwuid: "In case of error, an error number is returned, and NULL is stored in *result."
So, error returned, NOT -1 and errno.
Example from man:

    if (result == NULL) {
        if (s == 0)
            printf("Not found\n");
        else {
            errno = s;
            perror("getpwnam_r");
        }
        exit(EXIT_FAILURE);
    }

Alex Syrnikov added 2 commits August 21, 2020 21:14
from man getpwuid:
"In case of error, an error number is returned, and NULL is stored in *result."
Error returned, NOT -1 and errno.
Example from man:
if (result == NULL) {
    if (s == 0)
        printf("Not found\n");
    else {
        errno = s;
        perror("getpwnam_r");
    }
    exit(EXIT_FAILURE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

0 participants