hmm, getpwuid_r can return 0 but pw == NULL
This commit is contained in:
parent
9137350aa6
commit
b22f20c335
|
@ -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)
|
int sigar_user_name_get(sigar_t *sigar, int uid, char *buf, int buflen)
|
||||||
{
|
{
|
||||||
struct passwd *pw;
|
struct passwd *pw = NULL;
|
||||||
/* XXX cache lookup */
|
/* XXX cache lookup */
|
||||||
|
|
||||||
# ifdef HAVE_GETPWUID_R
|
# 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) {
|
if (getpwuid_r(uid, &pwbuf, buffer, sizeof(buffer), &pw) != 0) {
|
||||||
return errno;
|
return errno;
|
||||||
}
|
}
|
||||||
|
if (!pw) {
|
||||||
|
return ENOENT;
|
||||||
|
}
|
||||||
# else
|
# else
|
||||||
if ((pw = getpwuid(uid)) == NULL) {
|
if ((pw = getpwuid(uid)) == NULL) {
|
||||||
return errno;
|
return errno;
|
||||||
|
|
Loading…
Reference in New Issue