Fix utmp entry check in check_idle()

This commit is contained in:
Petar Kapris 2020-12-17 22:01:08 +01:00
parent d8f6dd3b5e
commit c272cf17db

View file

@ -858,8 +858,7 @@ void check_idle()
pstat = &status; /* point to status structure */
sprintf(path, "/proc/%d", utmpp->ut_pid);
if (utmpp->ut_type != USER_PROCESS || !utmpp->ut_user[0] || /* if not user process */
stat(path, pstat)) /* or if proc doesn't exist */
if (utmpp->ut_type != USER_PROCESS || stat(path, pstat)) /* if not user process, or if proc doesn't exist */
return; /* skip the utmp entry */
strncpy(user, utmpp->ut_user, sizeof(user) - 1); /* get user name */
user[sizeof(user) - 1] = '\0'; /* null terminate user name string */