Skip to content

Commit

Permalink
Check that grp points to something before using it.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomin1 committed Apr 28, 2020
1 parent b6ff364 commit 1c2fed1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/usermodel.cpp
Expand Up @@ -88,13 +88,17 @@ UserModel::UserModel(QObject *parent)
if (QDBusConnection::systemBus().interface()->isServiceRegistered(UserManagerService))
createInterface();
struct group *grp = getgrnam("users");
if (!grp) {
qCWarning(lcUsersLog) << "Could not read users group:" << strerror(errno);
} else {
for (int i = 0; grp->gr_mem[i] != nullptr; ++i) {
UserInfo user(QString(grp->gr_mem[i]));
if (user.isValid()) { // Skip invalid users here
m_users.append(user);
m_uidsToRows.insert(user.uid(), m_users.count()-1);
}
}
}
// grp must not be free'd
}

Expand Down

0 comments on commit 1c2fed1

Please sign in to comment.