Skip to content

Fix getpwuid_r error handling#3

Open
ghost wants to merge 2 commits intomasterfrom
unknown repository
Open

Fix getpwuid_r error handling#3
ghost wants to merge 2 commits intomasterfrom
unknown repository

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