hmm, getpwuid_r can return 0 but pw == NULL

This commit is contained in:
Doug MacEachern 2005-10-02 03:07:59 +00:00
parent 9137350aa6
commit b22f20c335
1 changed files with 4 additions and 1 deletions

View File

@ -229,7 +229,7 @@ SIGAR_DECLARE(char *) sigar_format_size(sigar_uint64_t size, char *buf)
int sigar_user_name_get(sigar_t *sigar, int uid, char *buf, int buflen)
{
struct passwd *pw;
struct passwd *pw = NULL;
/* XXX cache lookup */
# ifdef HAVE_GETPWUID_R
@ -239,6 +239,9 @@ int sigar_user_name_get(sigar_t *sigar, int uid, char *buf, int buflen)
if (getpwuid_r(uid, &pwbuf, buffer, sizeof(buffer), &pw) != 0) {
return errno;
}
if (!pw) {
return ENOENT;
}
# else
if ((pw = getpwuid(uid)) == NULL) {
return errno;