mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-24 02:42:48 +00:00
kio: fix possible null-pointer dereference
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
40c956e096
commit
c12103d15e
1 changed files with 16 additions and 15 deletions
|
@ -1751,25 +1751,26 @@ KFilePermissionsPropsPlugin::KFilePermissionsPropsPlugin( KPropertiesDialog *_pr
|
|||
QStringList groupList;
|
||||
QByteArray strUser;
|
||||
user = getpwuid(geteuid());
|
||||
if (user != 0L)
|
||||
if (user != 0L) {
|
||||
strUser = user->pw_name;
|
||||
|
||||
#ifdef HAVE_GETGROUPLIST
|
||||
// pick the groups to which the user belongs
|
||||
int groupCount = 0;
|
||||
QVarLengthArray<gid_t> groups;
|
||||
if (getgrouplist(strUser, user->pw_gid, NULL, &groupCount) < 0) {
|
||||
groups.resize(groupCount);
|
||||
if (groups.data())
|
||||
getgrouplist(strUser, user->pw_gid, groups.data(), &groupCount);
|
||||
else
|
||||
groupCount = 0;
|
||||
}
|
||||
// pick the groups to which the user belongs
|
||||
int groupCount = 0;
|
||||
QVarLengthArray<gid_t> groups;
|
||||
if (getgrouplist(strUser, user->pw_gid, NULL, &groupCount) < 0) {
|
||||
groups.resize(groupCount);
|
||||
if (groups.data())
|
||||
getgrouplist(strUser, user->pw_gid, groups.data(), &groupCount);
|
||||
else
|
||||
groupCount = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < groupCount; i++) {
|
||||
struct group *mygroup = getgrgid(groups[i]);
|
||||
if (mygroup)
|
||||
groupList += QString::fromLocal8Bit(mygroup->gr_name);
|
||||
for (i = 0; i < groupCount; i++) {
|
||||
struct group *mygroup = getgrgid(groups[i]);
|
||||
if (mygroup)
|
||||
groupList += QString::fromLocal8Bit(mygroup->gr_name);
|
||||
}
|
||||
}
|
||||
#endif // HAVE_GETGROUPLIST
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue